diff options
author | Jan Habermann <jan@habermann24.com> | 2014-04-03 01:52:42 +0200 |
---|---|---|
committer | Jan Habermann <jan@habermann24.com> | 2014-04-03 01:52:42 +0200 |
commit | 98e69078d5e2fe9a13bd912bbb5da00be4d43497 (patch) | |
tree | d4da280a5a00d4ace96a3dab58bc5fbe14b93b5e /activerecord/test/cases/associations | |
parent | 165d93b22ff5f8798296bd5d7642d0ddb8996c74 (diff) | |
download | rails-98e69078d5e2fe9a13bd912bbb5da00be4d43497.tar.gz rails-98e69078d5e2fe9a13bd912bbb5da00be4d43497.tar.bz2 rails-98e69078d5e2fe9a13bd912bbb5da00be4d43497.zip |
Properly handle scoping with has_many :through. Fixes #14537.
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/has_many_through_associations_test.rb | 12 |
1 files changed, 12 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 026a7fe635..fee0d2c627 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -1105,4 +1105,16 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase def test_has_many_through_with_includes_in_through_association_scope assert_not_empty posts(:welcome).author_address_extra_with_address end + + 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 |