class TransitionCollectionWithBeforeCallbackHaltTest
Public Instance Methods
save()
click to toggle source
# File test/unit/transition_collection_test.rb, line 1020 def save @saved = true end
setup()
click to toggle source
# File test/unit/transition_collection_test.rb, line 1016 def setup @klass = Class.new do attr_reader :saved def save @saved = true end end @before_count = 0 @after_count = 0 @machine = StateMachine::Machine.new(@klass, :initial => :parked, :action => :save) @machine.state :idling @machine.event :ignite @machine.before_transition {@before_count += 1; throw :halt} @machine.before_transition {@before_count += 1} @machine.after_transition {@after_count += 1} @machine.around_transition {|block| @before_count += 1; block.call; @after_count += 1} @object = @klass.new @transitions = StateMachine::TransitionCollection.new([ StateMachine::Transition.new(@object, @machine, :ignite, :parked, :idling) ]) @result = @transitions.perform end
test_should_not_persist_state()
click to toggle source
# File test/unit/transition_collection_test.rb, line 1048 def test_should_not_persist_state assert_equal 'parked', @object.state end
test_should_not_run_action()
click to toggle source
# File test/unit/transition_collection_test.rb, line 1052 def test_should_not_run_action assert !@object.saved end
test_should_not_run_after_callbacks()
click to toggle source
# File test/unit/transition_collection_test.rb, line 1060 def test_should_not_run_after_callbacks assert_equal 0, @after_count end
test_should_not_run_further_before_callbacks()
click to toggle source
# File test/unit/transition_collection_test.rb, line 1056 def test_should_not_run_further_before_callbacks assert_equal 1, @before_count end
test_should_not_succeed()
click to toggle source
# File test/unit/transition_collection_test.rb, line 1044 def test_should_not_succeed assert_equal false, @result end