diff options
author | Ivan Antropov <antropov.ivan@gmail.com> | 2013-11-10 12:28:54 +0700 |
---|---|---|
committer | Ivan Antropov <antropov.ivan@gmail.com> | 2013-11-17 12:20:50 +0700 |
commit | ec0928076529e8f0b5a4ad58c95cfa1fe6ed5b60 (patch) | |
tree | 30ebc3fd0590552a2b175b83c5d99c6b0f347c39 /activerecord/test/cases | |
parent | fa13d8e6d926c601070104c7075be39618280272 (diff) | |
download | rails-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')
-rw-r--r-- | activerecord/test/cases/associations/has_many_through_associations_test.rb | 14 | ||||
-rw-r--r-- | activerecord/test/cases/relation_test.rb | 4 |
2 files changed, 17 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 diff --git a/activerecord/test/cases/relation_test.rb b/activerecord/test/cases/relation_test.rb index 70d113fb39..e83aafc842 100644 --- a/activerecord/test/cases/relation_test.rb +++ b/activerecord/test/cases/relation_test.rb @@ -16,6 +16,10 @@ module ActiveRecord def self.connection Post.connection end + + def self.table_name + 'fake_table' + end end def test_construction |