diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-06-01 09:35:26 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-06-29 06:35:10 +0900 |
commit | 99912ed92635600eb6b03959c33638cb62f1bdca (patch) | |
tree | 0fd962bd060ec0ecbc42673e8096efd31d6f9f69 /activerecord/test/cases | |
parent | 65b02ea56026b8747be65d64d99d6c90f7d04083 (diff) | |
download | rails-99912ed92635600eb6b03959c33638cb62f1bdca.tar.gz rails-99912ed92635600eb6b03959c33638cb62f1bdca.tar.bz2 rails-99912ed92635600eb6b03959c33638cb62f1bdca.zip |
Fix to scoping is correctly restored
This regression was caused by #23004.
If STI subclass is using scoping in parent class scoping,
`current_scope` in subclass is never restored.
I fixed to restore `current_scope` to previous value correctly.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/scoping/relation_scoping_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/scoping/relation_scoping_test.rb b/activerecord/test/cases/scoping/relation_scoping_test.rb index 8535be8402..10553bf057 100644 --- a/activerecord/test/cases/scoping/relation_scoping_test.rb +++ b/activerecord/test/cases/scoping/relation_scoping_test.rb @@ -229,6 +229,15 @@ class RelationScopingTest < ActiveRecord::TestCase end end + def test_scoping_is_correctly_restored + Comment.unscoped do + SpecialComment.unscoped.created + end + + assert_nil Comment.current_scope + assert_nil SpecialComment.current_scope + end + def test_circular_joins_with_scoping_does_not_crash posts = Post.joins(comments: :post).scoping do Post.first(10) |