test/plugins/state_machine_test.rb in rocketjob-2.1.3 vs test/plugins/state_machine_test.rb in rocketjob-3.0.0.alpha
- old
+ new
@@ -6,12 +6,12 @@
class Test
include RocketJob::Plugins::Document
include RocketJob::Plugins::StateMachine
- key :name
- key :state
+ field :name, type: String
+ field :state, type: String
validates_presence_of :name, :state
aasm column: :state do
state :pending, initial: true
state :enabled
@@ -31,22 +31,22 @@
@doc.destroy if @doc && !@doc.new_record?
end
describe '#aasm_write_state' do
it 'raises an exception when a validation fails on create!' do
- assert_raises MongoMapper::DocumentNotValid do
+ assert_raises Mongoid::Errors::Validations do
@doc = Test.create!
end
end
it 'raises an exception when a validation fails on save' do
- assert_raises MongoMapper::DocumentNotValid do
+ assert_raises Mongoid::Errors::Validations do
@doc.save!
end
end
it 'raises an exception when a validation fails on state transition with save' do
- assert_raises MongoMapper::DocumentNotValid do
+ assert_raises Mongoid::Errors::Validations do
@doc.enable!
end
assert @doc.pending?
refute @doc.valid?
end