aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/state_machine/machine_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/test/state_machine/machine_test.rb')
-rw-r--r--activemodel/test/state_machine/machine_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activemodel/test/state_machine/machine_test.rb b/activemodel/test/state_machine/machine_test.rb
index 34a4b384ce..64dea42b1f 100644
--- a/activemodel/test/state_machine/machine_test.rb
+++ b/activemodel/test/state_machine/machine_test.rb
@@ -4,9 +4,18 @@ class MachineTestSubject
include ActiveModel::StateMachine
state_machine do
+ state :open
+ state :closed
end
state_machine :initial => :foo do
+ event :shutdown do
+ transitions :from => :open, :to => :closed
+ end
+
+ event :timeout do
+ transitions :from => :open, :to => :closed
+ end
end
state_machine :extra, :initial => :bar do
@@ -25,4 +34,8 @@ class StateMachineMachineTest < ActiveModel::TestCase
test "accesses non-default state machine" do
assert_kind_of ActiveModel::StateMachine::Machine, MachineTestSubject.state_machine(:extra)
end
+
+ test "finds events for given state" do
+ assert_equal [:shutdown, :timeout], MachineTestSubject.state_machine.events_for(:open)
+ end
end \ No newline at end of file