diff options
author | Rafael Mendonça França <rafael.franca@plataformatec.com.br> | 2014-04-22 17:20:52 -0500 |
---|---|---|
committer | Rafael Mendonça França <rafael.franca@plataformatec.com.br> | 2014-04-22 17:20:52 -0500 |
commit | c26a690b9964d90eea33f33a513ae9c349678cc0 (patch) | |
tree | 202768bd10efa7f1ad8395f324ba0e95f2b6ffc0 /activerecord/test/cases/associations | |
parent | 148d909380cf9b85a51875a6790a6d69a2d0d693 (diff) | |
parent | 47a04b8bbf35238639b00bfab500a84607d8d871 (diff) | |
download | rails-c26a690b9964d90eea33f33a513ae9c349678cc0.tar.gz rails-c26a690b9964d90eea33f33a513ae9c349678cc0.tar.bz2 rails-c26a690b9964d90eea33f33a513ae9c349678cc0.zip |
Merge pull request #14573 from habermann24/has_many_through_fix
Properly handle scoping with has_many :through. Fixes #14537.
Conflicts:
activerecord/CHANGELOG.md
activerecord/test/cases/associations/has_many_through_associations_test.rb
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/has_many_through_associations_test.rb | 11 |
1 files changed, 11 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 6675e19dd9..e30577fb49 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -1116,5 +1116,16 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase club.reload assert_equal [member], club.favourites + + def test_has_many_through_unscope_default_scope + post = Post.create!(:title => 'Beaches', :body => "I like beaches!") + Reader.create! :person => people(:david), :post => post + LazyReader.create! :person => people(:susan), :post => post + + assert_equal 2, post.people.to_a.size + assert_equal 1, post.lazy_people.to_a.size + + assert_equal 2, post.lazy_readers_unscope_skimmers.to_a.size + assert_equal 2, post.lazy_people_unscope_skimmers.to_a.size end end |