diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-09-04 17:24:34 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-09-04 17:24:34 -0700 |
commit | ed7c851c4b43936453cacf41013a49fa57854ea5 (patch) | |
tree | abff51c61bc63a16f4ca53dd9170c392299095f6 /activerecord/test/cases | |
parent | 2e6625fb775783cdbc721391be18a073a5b9a9c8 (diff) | |
parent | 4abbdbdf1656e9bed6f744723a901cbaf6878df4 (diff) | |
download | rails-ed7c851c4b43936453cacf41013a49fa57854ea5.tar.gz rails-ed7c851c4b43936453cacf41013a49fa57854ea5.tar.bz2 rails-ed7c851c4b43936453cacf41013a49fa57854ea5.zip |
Merge pull request #16788 from codeodor/fix-16761
Skip StatementCache for eager loaded associations
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/scoping/default_scoping_test.rb | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/activerecord/test/cases/scoping/default_scoping_test.rb b/activerecord/test/cases/scoping/default_scoping_test.rb index 9a4d8c6740..a5c4404175 100644 --- a/activerecord/test/cases/scoping/default_scoping_test.rb +++ b/activerecord/test/cases/scoping/default_scoping_test.rb @@ -1,9 +1,10 @@ require 'cases/helper' require 'models/post' +require 'models/comment' require 'models/developer' class DefaultScopingTest < ActiveRecord::TestCase - fixtures :developers, :posts + fixtures :developers, :posts, :comments def test_default_scope expected = Developer.all.merge!(:order => 'salary DESC').to_a.collect { |dev| dev.salary } @@ -378,6 +379,24 @@ class DefaultScopingTest < ActiveRecord::TestCase assert_equal 1, DeveloperWithIncludes.where(:audit_logs => { :message => 'foo' }).count end + def test_default_scope_with_references_works_through_collection_association + post = PostWithCommentWithDefaultScopeReferencesAssociation.create!(title: "Hello World", body: "Here we go.") + comment = post.comment_with_default_scope_references_associations.create!(body: "Great post.", developer_id: Developer.first.id) + assert_equal comment, post.comment_with_default_scope_references_associations.to_a.first + end + + def test_default_scope_with_references_works_through_association + post = PostWithCommentWithDefaultScopeReferencesAssociation.create!(title: "Hello World", body: "Here we go.") + comment = post.comment_with_default_scope_references_associations.create!(body: "Great post.", developer_id: Developer.first.id) + assert_equal comment, post.first_comment + end + + def test_default_scope_with_references_works_with_find_by + post = PostWithCommentWithDefaultScopeReferencesAssociation.create!(title: "Hello World", body: "Here we go.") + comment = post.comment_with_default_scope_references_associations.create!(body: "Great post.", developer_id: Developer.first.id) + assert_equal comment, CommentWithDefaultScopeReferencesAssociation.find_by(id: comment.id) + end + unless in_memory_db? def test_default_scope_is_threadsafe threads = [] |