diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-11-29 10:09:42 -0800 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-11-29 10:09:42 -0800 |
commit | 2169603385a447256d713873be6b2fbb6e2591fa (patch) | |
tree | 8a56b9264808c0e7b0cba8fc895e364a75c3bc05 /activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb | |
parent | d534c8fbe26dbc1101d80ad3af4cf166d0e3cda8 (diff) | |
parent | c347b3c06c2867badce5e22ecfbed3e972960c29 (diff) | |
download | rails-2169603385a447256d713873be6b2fbb6e2591fa.tar.gz rails-2169603385a447256d713873be6b2fbb6e2591fa.tar.bz2 rails-2169603385a447256d713873be6b2fbb6e2591fa.zip |
Merge pull request #3636 from joshsusser/master
association methods are now generated in modules
Diffstat (limited to 'activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb')
-rw-r--r-- | activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb index 34d90cc395..32a3389422 100644 --- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb @@ -77,7 +77,7 @@ end class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase fixtures :accounts, :companies, :categories, :posts, :categories_posts, :developers, :projects, :developers_projects, - :parrots, :pirates, :treasures, :price_estimates, :tags, :taggings + :parrots, :pirates, :parrots_pirates, :treasures, :price_estimates, :tags, :taggings def setup_data_for_habtm_case ActiveRecord::Base.connection.execute('delete from countries_treaties') @@ -445,6 +445,26 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase assert david.projects(true).empty? end + def test_destroy_associations_destroys_multiple_associations + george = parrots(:george) + assert !george.pirates.empty? + assert !george.treasures.empty? + + assert_no_difference "Pirate.count" do + assert_no_difference "Treasure.count" do + george.destroy_associations + end + end + + join_records = Parrot.connection.select_all("SELECT * FROM parrots_pirates WHERE parrot_id = #{george.id}") + assert join_records.empty? + assert george.pirates(true).empty? + + join_records = Parrot.connection.select_all("SELECT * FROM parrots_treasures WHERE parrot_id = #{george.id}") + assert join_records.empty? + assert george.treasures(true).empty? + end + def test_deprecated_push_with_attributes_was_removed jamis = developers(:jamis) assert_raise(NoMethodError) do |