From 19c80718afea8cf8f56ee68fcfbe325d54c02906 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sat, 21 Apr 2018 21:27:50 +0900 Subject: Ensure that `ids_reader` respects dirty target whether target is loaded or not Currently `ids_reader` doesn't respect dirty target when the target is not loaded yet unlike `collection.size`. I believe the inconsistency is a bug, fixes the `ids_reader` to behave consistently regardless of whether target is loaded or not. --- activerecord/test/cases/associations/has_many_associations_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index feb7390e2c..2e0a7ab1ab 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -989,7 +989,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_equal 0, post.readers.size post.readers.reset post.readers.build - assert_equal [], post.reader_ids + assert_equal [nil], post.reader_ids assert_equal 1, post.readers.size end @@ -999,7 +999,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_empty post.readers post.readers.reset post.readers.build - assert_equal [], post.reader_ids + assert_equal [nil], post.reader_ids assert_not_empty post.readers end -- cgit v1.2.3