state_manager 0.2.13 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +0 -1
- data/lib/state_manager/resource.rb +1 -1
- data/lib/state_manager/state.rb +5 -0
- data/lib/state_manager/version.rb +1 -1
- data/test/basic_test.rb +20 -0
- data/test/helper.rb +0 -1
- metadata +1 -1
data/Gemfile
CHANGED
data/lib/state_manager/state.rb
CHANGED
data/test/basic_test.rb
CHANGED
@@ -3,6 +3,9 @@ require 'helper'
|
|
3
3
|
class BasicTest < Minitest::Test
|
4
4
|
|
5
5
|
class PostStates < StateManager::Base
|
6
|
+
|
7
|
+
attr_accessor :title
|
8
|
+
|
6
9
|
state :unsubmitted do
|
7
10
|
event :submit, :transitions_to => 'submitted.awaiting_review'
|
8
11
|
end
|
@@ -20,12 +23,22 @@ class BasicTest < Minitest::Test
|
|
20
23
|
end
|
21
24
|
state :active
|
22
25
|
state :rejected
|
26
|
+
|
27
|
+
class Active
|
28
|
+
def entered
|
29
|
+
state_manager.title = title
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
23
33
|
end
|
24
34
|
|
25
35
|
class Post
|
36
|
+
|
26
37
|
attr_accessor :state
|
27
38
|
extend StateManager::Resource
|
28
39
|
state_manager :state
|
40
|
+
|
41
|
+
attr_accessor :title
|
29
42
|
end
|
30
43
|
|
31
44
|
class PostWithInitialState
|
@@ -136,4 +149,11 @@ class BasicTest < Minitest::Test
|
|
136
149
|
assert_state 'submitted.awaiting_review'
|
137
150
|
end
|
138
151
|
|
152
|
+
def test_property_proxying
|
153
|
+
@resource = Post.new
|
154
|
+
@resource.title = 'some title'
|
155
|
+
@resource.state_manager.transition_to 'active'
|
156
|
+
assert_equal 'some title', @resource.state_manager.title
|
157
|
+
end
|
158
|
+
|
139
159
|
end
|
data/test/helper.rb
CHANGED