aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/scoping/relation_scoping_test.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-10-14 16:16:13 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-10-14 16:16:29 -0700
commitb59d47d82e6ecb4308b675875b5a62c79858645e (patch)
tree85ecbf4d959d64f4ba7a69f87af52943231615e7 /activerecord/test/cases/scoping/relation_scoping_test.rb
parent6bb040b55748269dd2cb2ae3a36fa54ca7c70c5e (diff)
downloadrails-b59d47d82e6ecb4308b675875b5a62c79858645e.tar.gz
rails-b59d47d82e6ecb4308b675875b5a62c79858645e.tar.bz2
rails-b59d47d82e6ecb4308b675875b5a62c79858645e.zip
break cache if we're inside a "scoping" call. fixes #17052
For now, we don't want to take "scoping" calls in to account when calculating cache keys for relations, so just opt-out.
Diffstat (limited to 'activerecord/test/cases/scoping/relation_scoping_test.rb')
-rw-r--r--activerecord/test/cases/scoping/relation_scoping_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/scoping/relation_scoping_test.rb b/activerecord/test/cases/scoping/relation_scoping_test.rb
index 8e512e118a..c63fea15f2 100644
--- a/activerecord/test/cases/scoping/relation_scoping_test.rb
+++ b/activerecord/test/cases/scoping/relation_scoping_test.rb
@@ -15,6 +15,16 @@ class RelationScopingTest < ActiveRecord::TestCase
developers(:david)
end
+ def test_unscoped_breaks_caching
+ author = authors :mary
+ assert_nil author.first_post
+ post = FirstPost.unscoped do
+ author = authors :mary
+ author.reload.first_post
+ end
+ assert post
+ end
+
def test_reverse_order
assert_equal Developer.order("id DESC").to_a.reverse, Developer.order("id DESC").reverse_order
end