aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_many_associations_test.rb
diff options
context:
space:
mode:
authorrobertomiranda <rjmaltamar@gmail.com>2013-01-18 07:56:05 -0500
committerrobertomiranda <rjmaltamar@gmail.com>2013-01-18 07:56:05 -0500
commit7baecc48028e2d0cb57936ad10b9102ed129c9f9 (patch)
tree77e65e64c592e9f75cb849f851eb4dedb376c2e1 /activerecord/test/cases/associations/has_many_associations_test.rb
parent4095c08729a188e6ebc24f86d60a10bc01053d9b (diff)
downloadrails-7baecc48028e2d0cb57936ad10b9102ed129c9f9.tar.gz
rails-7baecc48028e2d0cb57936ad10b9102ed129c9f9.tar.bz2
rails-7baecc48028e2d0cb57936ad10b9102ed129c9f9.zip
User Rails 4 find_by
Diffstat (limited to 'activerecord/test/cases/associations/has_many_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index 7e6c7d5862..3f9667fa94 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -253,7 +253,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
post = Post.first
assert_equal [], person.readers
- assert_nil person.readers.find_by_post_id(post.id)
+ assert_nil person.readers.find_by(post_id: post.id)
person.readers.create(:post_id => post.id)
@@ -311,7 +311,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
def test_dynamic_find_should_respect_association_order
assert_equal companies(:second_client), companies(:first_firm).clients_sorted_desc.where("type = 'Client'").first
- assert_equal companies(:second_client), companies(:first_firm).clients_sorted_desc.find_by_type('Client')
+ assert_equal companies(:second_client), companies(:first_firm).clients_sorted_desc.find_by(type: 'Client')
end
def test_cant_save_has_many_readonly_association
@@ -878,7 +878,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal [client_id], Client.destroyed_client_ids[firm.id]
# Should be destroyed since the association is dependent.
- assert_nil Client.find_by_id(client_id)
+ assert_nil Client.find_by(id: client_id)
end
def test_clearing_an_exclusively_dependent_association_collection
@@ -898,7 +898,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal [], Client.destroyed_client_ids[firm.id]
# Should be destroyed since the association is exclusively dependent.
- assert_nil Client.find_by_id(client_id)
+ assert_nil Client.find_by(id: client_id)
end
def test_dependent_association_respects_optional_conditions_on_delete
@@ -947,7 +947,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
old_record = firm.clients_using_primary_key_with_delete_all.first
firm = Firm.first
firm.destroy
- assert_nil Client.find_by_id(old_record.id)
+ assert_nil Client.find_by(id: old_record.id)
end
def test_creation_respects_hash_condition
@@ -973,7 +973,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
def test_deleting_a_item_which_is_not_in_the_collection
force_signal37_to_load_all_clients_of_firm
- summit = Client.find_by_name('Summit')
+ summit = Client.find_by(name: 'Summit')
companies(:first_firm).clients_of_firm.delete(summit)
assert_equal 1, companies(:first_firm).clients_of_firm.size
assert_equal 1, companies(:first_firm).clients_of_firm(true).size
@@ -1299,7 +1299,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
def test_dynamic_find_should_respect_association_order_for_through
assert_equal Comment.find(10), authors(:david).comments_desc.where("comments.type = 'SpecialComment'").first
- assert_equal Comment.find(10), authors(:david).comments_desc.find_by_type('SpecialComment')
+ assert_equal Comment.find(10), authors(:david).comments_desc.find_by(type: 'SpecialComment')
end
def test_has_many_through_respects_hash_conditions