diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-03-09 19:20:48 -0300 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-03-09 19:21:33 -0300 |
commit | 6e5ab6fccb55727ef2e32c30a77a48c595316cae (patch) | |
tree | 3f95cd0bd4186b1e5ab34158cd41c67bb379df99 /activerecord/test | |
parent | f56cdbdfb2cb0f9f989b377b21d6d30d3d4f7d03 (diff) | |
download | rails-6e5ab6fccb55727ef2e32c30a77a48c595316cae.tar.gz rails-6e5ab6fccb55727ef2e32c30a77a48c595316cae.tar.bz2 rails-6e5ab6fccb55727ef2e32c30a77a48c595316cae.zip |
Change uniq validation with conditions examples to use where with hashes
Take the opportunity to showcase where.not.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/validations/uniqueness_validation_test.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/test/cases/validations/uniqueness_validation_test.rb b/activerecord/test/cases/validations/uniqueness_validation_test.rb index 150e3c5461..29b45944aa 100644 --- a/activerecord/test/cases/validations/uniqueness_validation_test.rb +++ b/activerecord/test/cases/validations/uniqueness_validation_test.rb @@ -348,7 +348,7 @@ class UniquenessValidationTest < ActiveRecord::TestCase end def test_validate_uniqueness_with_conditions - Topic.validates_uniqueness_of :title, conditions: -> { where('approved = ?', true) } + Topic.validates_uniqueness_of :title, conditions: -> { where(approved: true) } Topic.create("title" => "I'm a topic", "approved" => true) Topic.create("title" => "I'm an unapproved topic", "approved" => false) @@ -361,7 +361,7 @@ class UniquenessValidationTest < ActiveRecord::TestCase def test_validate_uniqueness_with_non_callable_conditions_is_not_supported assert_raises(ArgumentError) { - Topic.validates_uniqueness_of :title, conditions: Topic.where('approved = ?', true) + Topic.validates_uniqueness_of :title, conditions: Topic.where(approved: true) } end |