diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-03-20 10:32:24 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-03-20 10:32:24 +0000 |
commit | 5b1a1bf5bfc520248285b036672146122dd2a815 (patch) | |
tree | 31d82a9155db6c9e553888da6375bd89fdb122cf /activemodel/test/state_machine/event_test.rb | |
parent | 93e2d378df5f599e3e48e74932f37e1c679f633e (diff) | |
download | rails-5b1a1bf5bfc520248285b036672146122dd2a815.tar.gz rails-5b1a1bf5bfc520248285b036672146122dd2a815.tar.bz2 rails-5b1a1bf5bfc520248285b036672146122dd2a815.zip |
Make Active Model test suite similar to Active Record
Diffstat (limited to 'activemodel/test/state_machine/event_test.rb')
-rw-r--r-- | activemodel/test/state_machine/event_test.rb | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/activemodel/test/state_machine/event_test.rb b/activemodel/test/state_machine/event_test.rb deleted file mode 100644 index 64dc8c4875..0000000000 --- a/activemodel/test/state_machine/event_test.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'test_helper' - -class EventTest < ActiveModel::TestCase - def setup - @state_name = :close_order - @success = :success_callback - end - - def new_event - @event = ActiveModel::StateMachine::Event.new(nil, @state_name, {:success => @success}) do - transitions :to => :closed, :from => [:open, :received] - end - end - - test 'should set the name' do - assert_equal @state_name, new_event.name - end - - test 'should set the success option' do - assert_equal @success, new_event.success - end - - test 'should create StateTransitions' do - ActiveModel::StateMachine::StateTransition.expects(:new).with(:to => :closed, :from => :open) - ActiveModel::StateMachine::StateTransition.expects(:new).with(:to => :closed, :from => :received) - new_event - end -end - -class EventBeingFiredTest < ActiveModel::TestCase - test 'should raise an AASM::InvalidTransition error if the transitions are empty' do - event = ActiveModel::StateMachine::Event.new(nil, :event) - - assert_raise ActiveModel::StateMachine::InvalidTransition do - event.fire(nil) - end - end - - test 'should return the state of the first matching transition it finds' do - event = ActiveModel::StateMachine::Event.new(nil, :event) do - transitions :to => :closed, :from => [:open, :received] - end - - obj = stub - obj.stubs(:current_state).returns(:open) - - assert_equal :closed, event.fire(obj) - end -end |