Skip to content

Commit f2cf42f

Browse files
authored
MONGOID-5214 Make unscoped clear current scope or document that it does not (#5478)
1 parent e78a7ee commit f2cf42f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/mongoid/scopable.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ def scoped(options = nil)
175175
def unscoped
176176
if block_given?
177177
without_default_scope do
178-
yield(self)
178+
with_scope(nil) do
179+
yield(self)
180+
end
179181
end
180182
else
181183
queryable.unscoped

spec/mongoid/scopable_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,8 +1265,6 @@ class << Band
12651265
let(:c1) { Band.where(active: true) }
12661266

12671267
it 'restores previous scope' do
1268-
pending 'MONGOID-5214'
1269-
12701268
Band.with_scope(c1) do |crit|
12711269
Band.unscoped do |crit2|
12721270
Mongoid::Threaded.current_scope(Band).should be nil

0 commit comments

Comments
 (0)