aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
diff options
context:
space:
mode:
authorIvan Antropov <antropov.ivan@gmail.com>2013-11-10 12:28:54 +0700
committerIvan Antropov <antropov.ivan@gmail.com>2013-11-17 12:20:50 +0700
commitec0928076529e8f0b5a4ad58c95cfa1fe6ed5b60 (patch)
tree30ebc3fd0590552a2b175b83c5d99c6b0f347c39 /activerecord/test/cases/associations
parentfa13d8e6d926c601070104c7075be39618280272 (diff)
downloadrails-ec0928076529e8f0b5a4ad58c95cfa1fe6ed5b60.tar.gz
rails-ec0928076529e8f0b5a4ad58c95cfa1fe6ed5b60.tar.bz2
rails-ec0928076529e8f0b5a4ad58c95cfa1fe6ed5b60.zip
Fix insertion of records for hmt association with scope, fix #3548
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r--activerecord/test/cases/associations/has_many_through_associations_test.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb
index 47592f312e..8017ed169c 100644
--- a/activerecord/test/cases/associations/has_many_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb
@@ -1095,7 +1095,19 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
assert_equal [posts(:thinking)], person.reload.first_posts
end
- def test_has_many_through_with_includes_in_through_association_scope
+ test "has many through with includes in through association scope" do
assert_not_empty posts(:welcome).author_address_extra_with_address
end
+
+ test "insert records via has_many_through association with scope" do
+ club = Club.create!
+ member = Member.create!
+ Membership.create!(club: club, member: member)
+
+ club.favourites << member
+ assert_equal [member], club.favourites
+
+ club.reload
+ assert_equal [member], club.favourites
+ end
end