Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix: Transition shouldn't raise exception if state is persisted as a string #10

Merged
merged 1 commit into from

2 participants

Clemens Kofler Sven Fuchs
Clemens Kofler

No description provided.

Sven Fuchs
Owner

cool, thanks!

Sven Fuchs svenfuchs merged commit 613619d into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 1 deletion.
  1. +1 −1  lib/simple_states/event.rb
  2. +9 −0 test/states_test.rb
2  lib/simple_states/event.rb
View
@@ -48,7 +48,7 @@ def skip?(object, args)
end
def can_transition?(object)
- !options.from || object.state && Array(options.from).include?(object.state)
+ !options.from || object.state && Array(options.from).include?(object.state.to_sym)
end
def run_callbacks(object, type, args)
9 test/states_test.rb
View
@@ -29,6 +29,15 @@ class StatesTest < Test::Unit::TestCase
assert_raises(SimpleStates::TransitionException) { object.start }
end
+ test "doesn't raise TransitionException if the state is persisted as a string" do
+ klass = create_class { states :created, :started; event :start, :from => :created, :to => :started }
+ klass.class_eval { def state=(state); @state = state.to_s; end }
+
+ object = klass.new
+
+ assert_nothing_raised(SimpleStates::TransitionException) { object.start }
+ end
+
test "state? returns true if the object has the given state" do
object = create_class { event :start, :from => :created, :to => :started }.new
Something went wrong with that request. Please try again.