mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
Add tests for multiple named scopes
This commit is contained in:
parent
7ba401b991
commit
7eebc4c1a6
9 changed files with 30 additions and 12 deletions
|
@ -2,7 +2,7 @@ class SimpleNewDsl < ActiveRecord::Base
|
|||
include AASM
|
||||
aasm :column => :status
|
||||
aasm do
|
||||
state :unknown_scope
|
||||
state :unknown_scope, :another_unknown_scope
|
||||
state :new
|
||||
end
|
||||
end
|
||||
|
@ -11,7 +11,7 @@ class MultipleSimpleNewDsl < ActiveRecord::Base
|
|||
include AASM
|
||||
aasm :left, :column => :status
|
||||
aasm :left do
|
||||
state :unknown_scope
|
||||
state :unknown_scope, :another_unknown_scope
|
||||
state :new
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ class SimpleMongoMapper
|
|||
key :status, String
|
||||
|
||||
aasm column: :status do
|
||||
state :unknown_scope
|
||||
state :unknown_scope, :another_unknown_scope
|
||||
state :next
|
||||
end
|
||||
end
|
||||
|
@ -17,7 +17,7 @@ class SimpleMongoMapperMultiple
|
|||
key :status, String
|
||||
|
||||
aasm :left, column: :status do
|
||||
state :unknown_scope
|
||||
state :unknown_scope, :another_unknown_scope
|
||||
state :next
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ class SimpleMongoid
|
|||
field :status, :type => String
|
||||
|
||||
aasm column: :status do
|
||||
state :unknown_scope
|
||||
state :unknown_scope, :another_unknown_scope
|
||||
state :new
|
||||
end
|
||||
end
|
||||
|
@ -17,7 +17,7 @@ class SimpleMongoidMultiple
|
|||
field :status, :type => String
|
||||
|
||||
aasm :left, column: :status do
|
||||
state :unknown_scope
|
||||
state :unknown_scope, :another_unknown_scope
|
||||
state :new
|
||||
end
|
||||
end
|
||||
|
|
|
@ -296,9 +296,12 @@ end
|
|||
|
||||
describe "named scopes with the new DSL" do
|
||||
context "Does not already respond_to? the scope name" do
|
||||
it "should add a scope" do
|
||||
it "should add a scope for each state" do
|
||||
expect(MultipleSimpleNewDsl).to respond_to(:unknown_scope)
|
||||
expect(MultipleSimpleNewDsl).to respond_to(:another_unknown_scope)
|
||||
|
||||
expect(MultipleSimpleNewDsl.unknown_scope.is_a?(ActiveRecord::Relation)).to be_truthy
|
||||
expect(MultipleSimpleNewDsl.another_unknown_scope.is_a?(ActiveRecord::Relation)).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -296,9 +296,12 @@ end
|
|||
|
||||
describe "named scopes with the new DSL" do
|
||||
context "Does not already respond_to? the scope name" do
|
||||
it "should add a scope" do
|
||||
it "should add a scope for each state" do
|
||||
expect(SimpleNewDsl).to respond_to(:unknown_scope)
|
||||
expect(SimpleNewDsl).to respond_to(:another_unknown_scope)
|
||||
|
||||
expect(SimpleNewDsl.unknown_scope.is_a?(ActiveRecord::Relation)).to be_truthy
|
||||
expect(SimpleNewDsl.another_unknown_scope.is_a?(ActiveRecord::Relation)).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -28,9 +28,12 @@ describe 'mongo_mapper' do
|
|||
describe "named scopes with the old DSL" do
|
||||
|
||||
context "Does not already respond_to? the scope name" do
|
||||
it "should add a scope" do
|
||||
it "should add a scope for each state" do
|
||||
expect(SimpleMongoMapperMultiple).to respond_to(:unknown_scope)
|
||||
expect(SimpleMongoMapperMultiple).to respond_to(:another_unknown_scope)
|
||||
|
||||
expect(SimpleMongoMapperMultiple.unknown_scope.class).to eq(MongoMapper::Plugins::Querying::DecoratedPluckyQuery)
|
||||
expect(SimpleMongoMapperMultiple.another_unknown_scope.class).to eq(MongoMapper::Plugins::Querying::DecoratedPluckyQuery)
|
||||
#expect(SimpleMongoMapperMultiple.unknown_scope.is_a?(ActiveRecord::Relation)).to be_truthy
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,9 +28,12 @@ describe 'mongo_mapper' do
|
|||
describe "named scopes with the old DSL" do
|
||||
|
||||
context "Does not already respond_to? the scope name" do
|
||||
it "should add a scope" do
|
||||
it "should add a scope for each state" do
|
||||
expect(SimpleMongoMapper).to respond_to(:unknown_scope)
|
||||
expect(SimpleMongoMapper).to respond_to(:another_unknown_scope)
|
||||
|
||||
expect(SimpleMongoMapper.unknown_scope.class).to eq(MongoMapper::Plugins::Querying::DecoratedPluckyQuery)
|
||||
expect(SimpleMongoMapper.another_unknown_scope.class).to eq(MongoMapper::Plugins::Querying::DecoratedPluckyQuery)
|
||||
#expect(SimpleMongoMapper.unknown_scope.is_a?(ActiveRecord::Relation)).to be_truthy
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,9 +24,12 @@ describe 'mongoid' do
|
|||
describe "named scopes with the old DSL" do
|
||||
|
||||
context "Does not already respond_to? the scope name" do
|
||||
it "should add a scope" do
|
||||
it "should add a scope for each state" do
|
||||
expect(SimpleMongoidMultiple).to respond_to(:unknown_scope)
|
||||
expect(SimpleMongoidMultiple).to respond_to(:another_unknown_scope)
|
||||
|
||||
expect(SimpleMongoidMultiple.unknown_scope.class).to eq(Mongoid::Criteria)
|
||||
expect(SimpleMongoidMultiple.another_unknown_scope.class).to eq(Mongoid::Criteria)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -24,9 +24,12 @@ describe 'mongoid' do
|
|||
describe "named scopes with the old DSL" do
|
||||
|
||||
context "Does not already respond_to? the scope name" do
|
||||
it "should add a scope" do
|
||||
it "should add a scope for each state" do
|
||||
expect(SimpleMongoid).to respond_to(:unknown_scope)
|
||||
expect(SimpleMongoid).to respond_to(:another_unknown_scope)
|
||||
|
||||
expect(SimpleMongoid.unknown_scope.class).to eq(Mongoid::Criteria)
|
||||
expect(SimpleMongoid.another_unknown_scope.class).to eq(Mongoid::Criteria)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue