aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2017-06-28 12:21:25 -0400
committerGitHub <noreply@github.com>2017-06-28 12:21:25 -0400
commit5241b265126ac9ecadf1414feaf4c42ceb056432 (patch)
treec3110b9ba5c0ffdfe9f209f9e3542d51cbebb84d /activerecord
parentbf7606d4ebae24e7ba49e34190c21cbad0a98640 (diff)
parente614be2d803f9dceae3c4192a7b9f75834dab3ea (diff)
downloadrails-5241b265126ac9ecadf1414feaf4c42ceb056432.tar.gz
rails-5241b265126ac9ecadf1414feaf4c42ceb056432.tar.bz2
rails-5241b265126ac9ecadf1414feaf4c42ceb056432.zip
Merge pull request #29602 from kamipo/use_reload_in_test_find_first_after_reload
Use `reload` in `test_find_first_after_reload`
Diffstat (limited to 'activerecord')
-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