Skip to content

Commit

Permalink
Merge pull request #2 from jafuentest/master
Browse files Browse the repository at this point in the history
Fixes issue #1
  • Loading branch information
douglaslise committed Jul 28, 2018
2 parents 32a6390 + 7007d9c commit 54a0a8f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
mongoid_enumerable (0.2.1)
mongoid_enumerable (0.2.2)
mongoid (>= 4.0)

GEM
Expand Down
4 changes: 1 addition & 3 deletions lib/mongoid_enumerable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ def self.included(base)
send(field_name) == value
end

base.define_singleton_method(method_name) do
base.where(field_name => value)
end
scope value, -> { where(field_name => value) }
end

base.define_singleton_method("all_#{field_name}") do
Expand Down
2 changes: 1 addition & 1 deletion lib/mongoid_enumerable/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module MongoidEnumerable
VERSION = "0.2.1"
VERSION = '0.2.2'
end
14 changes: 14 additions & 0 deletions spec/mongoid_enumerable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,19 @@

it { expect(another_klass).to_not respond_to(:st_completed)}
end

context 'when declared for a superclass' do
class SuperClass
include MongoidEnumerable
include Mongoid::Document
enumerable :status, %i(completed running failed waiting)
end

class SubClass < SuperClass; end

it 'preserves subclass in mongoid criterias' do
expect(SubClass.completed.klass).to equal(SubClass)
end
end
end
end

0 comments on commit 54a0a8f

Please sign in to comment.