Sha256: ecf42887b5d1ca50f665653bf4205e3e9499f8da4d58e43472bb4d38453c00f7
Contents?: true
Size: 1.66 KB
Versions: 3
Compression:
Stored size: 1.66 KB
Contents
require_relative '../test_helper' module Plugins # Unit Test for RocketJob::Job class StateMachineTest < Minitest::Test class Test include RocketJob::Plugins::Document include RocketJob::Plugins::StateMachine field :name, type: String field :state, type: String validates_presence_of :name, :state aasm column: :state, whiny_persistence: true do state :pending, initial: true state :enabled event :enable do transitions from: :pending, to: :enabled end end end describe RocketJob::Plugins::StateMachine do before do @doc = Test.new end after do @doc.destroy if @doc && !@doc.new_record? end describe '#create!' do it 'raises an exception when a validation fails on create!' do assert_raises Mongoid::Errors::Validations do @doc = Test.create! end end end describe '#save!' do it 'raises an exception when a validation fails on save' do assert_raises Mongoid::Errors::Validations do @doc.save! end end end describe '#transition!' do it 'raises an exception when a validation fails on state transition with save' do assert_raises Mongoid::Errors::Validations do @doc.enable! end assert @doc.pending? refute @doc.valid? end end describe '#transition' do it 'does not raise an exception when a validation fails on state transition without save' do @doc.enable assert @doc.enabled? end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rocketjob-3.5.2 | test/plugins/state_machine_test.rb |
rocketjob-3.5.1 | test/plugins/state_machine_test.rb |
rocketjob-3.5.0 | test/plugins/state_machine_test.rb |