diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-19 15:04:39 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-19 15:07:11 -0300 |
commit | 9ac81b954ab62077576d858042df918b2f7b305f (patch) | |
tree | d653748582185d552fdb939d4f00675a3ca6a21c /activerecord/test | |
parent | 008870e6a4043bd217738aa6f3cdda1f0ea74947 (diff) | |
parent | 30b76e5575c57056361741ebbede972f8ef477de (diff) | |
download | rails-9ac81b954ab62077576d858042df918b2f7b305f.tar.gz rails-9ac81b954ab62077576d858042df918b2f7b305f.tar.bz2 rails-9ac81b954ab62077576d858042df918b2f7b305f.zip |
Merge pull request #15772 from nbudin/sti_through_bug
Don't include inheritance column in the through_scope_attributes
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/has_many_through_associations_test.rb | 8 | ||||
-rw-r--r-- | activerecord/test/models/club.rb | 7 |
2 files changed, 15 insertions, 0 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 8641584c0c..ad2aa99af5 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -1139,4 +1139,12 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase assert_equal 2, post.lazy_readers_unscope_skimmers.to_a.size assert_equal 2, post.lazy_people_unscope_skimmers.to_a.size end + + def test_has_many_through_add_with_sti_middle_relation + club = SuperClub.create!(name: 'Fight Club') + member = Member.create!(name: 'Tyler Durden') + + club.members << member + assert_equal 1, SuperMembership.where(member_id: member.id, club_id: club.id).count + end end diff --git a/activerecord/test/models/club.rb b/activerecord/test/models/club.rb index a762ad4bb5..6ceafe5858 100644 --- a/activerecord/test/models/club.rb +++ b/activerecord/test/models/club.rb @@ -14,3 +14,10 @@ class Club < ActiveRecord::Base "I'm sorry sir, this is a *private* club, not a *pirate* club" end end + +class SuperClub < ActiveRecord::Base + self.table_name = "clubs" + + has_many :memberships, class_name: 'SuperMembership', foreign_key: 'club_id' + has_many :members, through: :memberships +end |