aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_many_associations_test.rb
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2014-04-28 20:58:17 -0400
committereileencodes <eileencodes@gmail.com>2014-04-28 20:58:17 -0400
commit748daa39610585829cdd52810870adf8e8711bfc (patch)
tree21c0d5b33d477749f392c1b7b85bcf9b3729589c /activerecord/test/cases/associations/has_many_associations_test.rb
parent96f90b51d26da0f0b6abf3f6af83bd772660ce26 (diff)
downloadrails-748daa39610585829cdd52810870adf8e8711bfc.tar.gz
rails-748daa39610585829cdd52810870adf8e8711bfc.tar.bz2
rails-748daa39610585829cdd52810870adf8e8711bfc.zip
add test to check that loaded and non laoded are the same
Test checks that SQL is the same for a loaded vs not loaded association (category.categorizations, category.categorization.delete_all vs category.cartegroization.delete_al). This was fixed for delete_all dependency but was not fixed for no (:nullify, or nil) dependency).
Diffstat (limited to 'activerecord/test/cases/associations/has_many_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index c79c0c87c5..2f5c9d6e1b 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -131,6 +131,19 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal(expected_sql, loaded_sql)
end
+ def test_delete_all_on_association_with_nil_dependency_is_the_same_as_not_loaded
+ author = authors :david
+ author.posts.create!(:title => "test", :body => "body")
+ author.reload
+ expected_sql = capture_sql { author.posts.delete_all }
+
+ author.posts.create!(:title => "test", :body => "body")
+ author.reload
+ author.posts.to_a
+ loaded_sql = capture_sql { author.posts.delete_all }
+ assert_equal(expected_sql, loaded_sql)
+ end
+
def test_building_the_associated_object_with_implicit_sti_base_class
firm = DependentFirm.new
company = firm.companies.build