aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-06-28 21:17:06 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-06-28 21:19:08 +0900
commite614be2d803f9dceae3c4192a7b9f75834dab3ea (patch)
treeafa0ed9c046cd5ef01cfb0a2d67fb82eecdac6f5 /activerecord/test/cases/associations
parentd766b64b7e137955b7c7dbab51d2b6e525de47c1 (diff)
downloadrails-e614be2d803f9dceae3c4192a7b9f75834dab3ea.tar.gz
rails-e614be2d803f9dceae3c4192a7b9f75834dab3ea.tar.bz2
rails-e614be2d803f9dceae3c4192a7b9f75834dab3ea.zip
Use `reload` in `test_find_first_after_reload`
And use `assert_same` instead of `assert_equal` and tiny fix assert message s/#reload/#reset/. Follow up of #29511.
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb20
1 files changed, 10 insertions, 10 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index 169e1a5449..b02653bbcc 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -745,35 +745,35 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
firm = Firm.all.merge!(order: "id").first
collection = firm.clients
- original_object_id = collection.first.object_id
- assert_equal original_object_id, collection.first.object_id, "Expected second call to #first to cache the same object"
+ original_object = collection.first
+ assert_same original_object, collection.first, "Expected second call to #first to cache the same object"
# It should return a different object, since the association has been reloaded
- assert_not_equal original_object_id, firm.clients.first.object_id, "Expected #first to return a new object"
+ assert_not_same original_object, firm.clients.first, "Expected #first to return a new object"
end
def test_find_first_after_reset
firm = Firm.all.merge!(order: "id").first
collection = firm.clients
- original_object_id = collection.first.object_id
- assert_equal original_object_id, collection.first.object_id, "Expected second call to #first to cache the same object"
+ original_object = collection.first
+ assert_same original_object, collection.first, "Expected second call to #first to cache the same object"
collection.reset
# It should return a different object, since the association has been reloaded
- assert_not_equal original_object_id, collection.first.object_id, "Expected #first after #reload to return a new object"
+ assert_not_same original_object, collection.first, "Expected #first after #reset to return a new object"
end
def test_find_first_after_reload
firm = Firm.all.merge!(order: "id").first
collection = firm.clients
- original_object_id = collection.first.object_id
- assert_equal original_object_id, collection.first.object_id, "Expected second call to #first to cache the same object"
- collection.reset
+ original_object = collection.first
+ assert_same original_object, collection.first, "Expected second call to #first to cache the same object"
+ collection.reload
# It should return a different object, since the association has been reloaded
- assert_not_equal original_object_id, collection.first.object_id, "Expected #first after #reload to return a new object"
+ assert_not_same original_object, collection.first, "Expected #first after #reload to return a new object"
end
def test_find_all_with_include_and_conditions