test/basic_test.rb in state_manager-0.2.13 vs test/basic_test.rb in state_manager-0.3.0
- old
+ new
@@ -1,10 +1,13 @@
require 'helper'
class BasicTest < Minitest::Test
class PostStates < StateManager::Base
+
+ attr_accessor :title
+
state :unsubmitted do
event :submit, :transitions_to => 'submitted.awaiting_review'
end
state :submitted do
state :awaiting_review do
@@ -18,16 +21,26 @@
event :review, :transitions_to => 'submitted.reviewing'
end
end
state :active
state :rejected
+
+ class Active
+ def entered
+ state_manager.title = title
+ end
+ end
+
end
class Post
+
attr_accessor :state
extend StateManager::Resource
state_manager :state
+
+ attr_accessor :title
end
class PostWithInitialState
attr_accessor :state
extend StateManager::Resource
@@ -132,8 +145,15 @@
def test_transition_to_current_state
@resource = PostWithInitialState.new
assert_state 'submitted.awaiting_review'
@resource.state_manager.transition_to('submitted.awaiting_review')
assert_state 'submitted.awaiting_review'
+ end
+
+ def test_property_proxying
+ @resource = Post.new
+ @resource.title = 'some title'
+ @resource.state_manager.transition_to 'active'
+ assert_equal 'some title', @resource.state_manager.title
end
end