Skip to content

Commit

Permalink
Fix: always return Criteria from querable, see MONGOID-4177.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Oct 31, 2015
1 parent 59fced3 commit e20836b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ env:
- MONGOID_VERSION=3
- MONGOID_VERSION=4
- MONGOID_VERSION=5
- MONGOID_VERSION=HEAD

rvm:
- jruby-19mode
Expand Down
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ source 'https://rubygems.org'
gemspec name: 'mongoid-slug'

case version = ENV['MONGOID_VERSION'] || '5.0'
when 'HEAD'
gem 'mongoid', github: 'mongodb/mongoid'
gem 'mongoid_paranoia'
gem 'mongoid-observers'
when /^5/
gem 'mongoid', '~> 5.0'
gem 'mongoid_paranoia'
Expand Down
3 changes: 2 additions & 1 deletion lib/mongoid/slug.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ def find_by_slug!(*args)

def queryable
scope = Mongoid::Compatibility::Version.mongoid5? ? Threaded.current_scope : scope_stack.last
scope || Criteria.new(self) # Use Mongoid::Slug::Criteria for slugged documents.
return scope if scope && scope.is_a?(::Mongoid::Criteria)
Criteria.new(self) # Use Mongoid::Slug::Criteria for slugged documents.
end

# Indicates whether or not the document includes Mongoid::Paranoia
Expand Down

0 comments on commit e20836b

Please sign in to comment.