branston 0.3.6 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. data/lib/branston/app/controllers/scenarios_controller.rb +6 -5
  2. data/lib/branston/app/controllers/stories_controller.rb +101 -89
  3. data/lib/branston/app/models/story.rb +30 -1
  4. data/lib/branston/app/models/user.rb +4 -0
  5. data/lib/branston/app/views/iterations/index.html.erb +1 -1
  6. data/lib/branston/app/views/layouts/_header.html.erb +1 -2
  7. data/lib/branston/app/views/scenarios/_scenario.html.erb +6 -3
  8. data/lib/branston/app/views/scenarios/_scenarios.html.erb +4 -2
  9. data/lib/branston/app/views/stories/_form.html.erb +15 -4
  10. data/lib/branston/app/views/stories/_story.html.erb +26 -6
  11. data/lib/branston/app/views/stories/edit.html.erb +3 -3
  12. data/lib/branston/app/views/stories/index.html.erb +22 -3
  13. data/lib/branston/app/views/stories/new.html.erb +2 -2
  14. data/lib/branston/app/views/stories/show.html.erb +3 -3
  15. data/lib/branston/config/routes.rb +7 -4
  16. data/lib/branston/coverage/app-controllers-application_controller_rb.html +1 -1
  17. data/lib/branston/coverage/app-controllers-iterations_controller_rb.html +1 -1
  18. data/lib/branston/coverage/app-controllers-outcomes_controller_rb.html +1 -1
  19. data/lib/branston/coverage/app-controllers-preconditions_controller_rb.html +1 -1
  20. data/lib/branston/coverage/app-controllers-releases_controller_rb.html +1 -1
  21. data/lib/branston/coverage/app-controllers-scenarios_controller_rb.html +18 -12
  22. data/lib/branston/coverage/app-controllers-sessions_controller_rb.html +1 -1
  23. data/lib/branston/coverage/app-controllers-stories_controller_rb.html +193 -121
  24. data/lib/branston/coverage/app-controllers-user_roles_controller_rb.html +1 -1
  25. data/lib/branston/coverage/app-controllers-users_controller_rb.html +1 -1
  26. data/lib/branston/coverage/app-helpers-application_helper_rb.html +1 -1
  27. data/lib/branston/coverage/app-helpers-iterations_helper_rb.html +1 -1
  28. data/lib/branston/coverage/app-helpers-outcomes_helper_rb.html +1 -1
  29. data/lib/branston/coverage/app-helpers-preconditions_helper_rb.html +1 -1
  30. data/lib/branston/coverage/app-helpers-releases_helper_rb.html +1 -1
  31. data/lib/branston/coverage/app-helpers-sessions_helper_rb.html +1 -1
  32. data/lib/branston/coverage/app-helpers-stories_helper_rb.html +1 -1
  33. data/lib/branston/coverage/app-helpers-user_roles_helper_rb.html +1 -1
  34. data/lib/branston/coverage/app-models-iteration_rb.html +1 -1
  35. data/lib/branston/coverage/app-models-outcome_rb.html +1 -1
  36. data/lib/branston/coverage/app-models-participation_rb.html +1 -1
  37. data/lib/branston/coverage/app-models-precondition_rb.html +1 -1
  38. data/lib/branston/coverage/app-models-release_rb.html +1 -1
  39. data/lib/branston/coverage/app-models-scenario_rb.html +1 -1
  40. data/lib/branston/coverage/app-models-story_rb.html +192 -18
  41. data/lib/branston/coverage/app-models-user_rb.html +33 -9
  42. data/lib/branston/coverage/app-models-user_role_rb.html +1 -1
  43. data/lib/branston/coverage/index.html +13 -13
  44. data/lib/branston/coverage/lib-client_rb.html +1 -1
  45. data/lib/branston/coverage/lib-faker_extras_rb.html +1 -1
  46. data/lib/branston/coverage/lib-story_generator_rb.html +1 -1
  47. data/lib/branston/db/development.sqlite3 +0 -0
  48. data/lib/branston/db/migrate/20091223100903_add_status_to_story.rb +11 -0
  49. data/lib/branston/db/pristine.sqlite3 +0 -0
  50. data/lib/branston/db/schema.rb +5 -3
  51. data/lib/branston/db/test.sqlite3 +0 -0
  52. data/lib/branston/lib/branston.rb +4 -2
  53. data/lib/branston/log/development.log +4970 -0
  54. data/lib/branston/log/test.log +88225 -0
  55. data/lib/branston/test/blueprints.rb +10 -7
  56. data/lib/branston/test/functional/scenarios_controller_test.rb +22 -15
  57. data/lib/branston/test/functional/stories_controller_test.rb +51 -30
  58. data/lib/branston/test/unit/story_test.rb +47 -7
  59. data/lib/branston/test/unit/user_test.rb +4 -0
  60. data/lib/branston/tmp/performance/BrowsingTest#test_homepage_process_time_flat.txt +3 -2
  61. data/lib/branston/tmp/performance/BrowsingTest#test_homepage_process_time_graph.html +2041 -1307
  62. data/lib/branston/tmp/performance/BrowsingTest#test_homepage_process_time_tree.txt +7922 -7922
  63. data/lib/branston/vendor/plugins/state_machine/CHANGELOG.rdoc +298 -0
  64. data/lib/branston/vendor/plugins/state_machine/LICENSE +20 -0
  65. data/lib/branston/vendor/plugins/state_machine/README.rdoc +466 -0
  66. data/lib/branston/vendor/plugins/state_machine/Rakefile +98 -0
  67. data/lib/branston/vendor/plugins/state_machine/examples/AutoShop_state.png +0 -0
  68. data/lib/branston/vendor/plugins/state_machine/examples/Car_state.png +0 -0
  69. data/lib/branston/vendor/plugins/state_machine/examples/TrafficLight_state.png +0 -0
  70. data/lib/branston/vendor/plugins/state_machine/examples/Vehicle_state.png +0 -0
  71. data/lib/branston/vendor/plugins/state_machine/examples/auto_shop.rb +11 -0
  72. data/lib/branston/vendor/plugins/state_machine/examples/car.rb +19 -0
  73. data/lib/branston/vendor/plugins/state_machine/examples/merb-rest/controller.rb +51 -0
  74. data/lib/branston/vendor/plugins/state_machine/examples/merb-rest/model.rb +28 -0
  75. data/lib/branston/vendor/plugins/state_machine/examples/merb-rest/view_edit.html.erb +24 -0
  76. data/lib/branston/vendor/plugins/state_machine/examples/merb-rest/view_index.html.erb +23 -0
  77. data/lib/branston/vendor/plugins/state_machine/examples/merb-rest/view_new.html.erb +13 -0
  78. data/lib/branston/vendor/plugins/state_machine/examples/merb-rest/view_show.html.erb +17 -0
  79. data/lib/branston/vendor/plugins/state_machine/examples/rails-rest/controller.rb +43 -0
  80. data/lib/branston/vendor/plugins/state_machine/examples/rails-rest/migration.rb +11 -0
  81. data/lib/branston/vendor/plugins/state_machine/examples/rails-rest/model.rb +23 -0
  82. data/lib/branston/vendor/plugins/state_machine/examples/rails-rest/view_edit.html.erb +25 -0
  83. data/lib/branston/vendor/plugins/state_machine/examples/rails-rest/view_index.html.erb +23 -0
  84. data/lib/branston/vendor/plugins/state_machine/examples/rails-rest/view_new.html.erb +14 -0
  85. data/lib/branston/vendor/plugins/state_machine/examples/rails-rest/view_show.html.erb +17 -0
  86. data/lib/branston/vendor/plugins/state_machine/examples/traffic_light.rb +7 -0
  87. data/lib/branston/vendor/plugins/state_machine/examples/vehicle.rb +31 -0
  88. data/lib/branston/vendor/plugins/state_machine/init.rb +1 -0
  89. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/assertions.rb +36 -0
  90. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/callback.rb +189 -0
  91. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/condition_proxy.rb +94 -0
  92. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/eval_helpers.rb +67 -0
  93. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/event.rb +252 -0
  94. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/event_collection.rb +122 -0
  95. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/extensions.rb +149 -0
  96. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/guard.rb +230 -0
  97. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/integrations/active_record/locale.rb +11 -0
  98. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/integrations/active_record/observer.rb +41 -0
  99. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/integrations/active_record.rb +492 -0
  100. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/integrations/data_mapper/observer.rb +139 -0
  101. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/integrations/data_mapper.rb +351 -0
  102. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/integrations/sequel.rb +322 -0
  103. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/integrations.rb +68 -0
  104. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/machine.rb +1467 -0
  105. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/machine_collection.rb +155 -0
  106. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/matcher.rb +123 -0
  107. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/matcher_helpers.rb +54 -0
  108. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/node_collection.rb +152 -0
  109. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/state.rb +249 -0
  110. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/state_collection.rb +112 -0
  111. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/transition.rb +394 -0
  112. data/lib/branston/vendor/plugins/state_machine/lib/state_machine.rb +388 -0
  113. data/lib/branston/vendor/plugins/state_machine/state_machine.gemspec +30 -0
  114. data/lib/branston/vendor/plugins/state_machine/tasks/state_machine.rake +1 -0
  115. data/lib/branston/vendor/plugins/state_machine/tasks/state_machine.rb +30 -0
  116. data/lib/branston/vendor/plugins/state_machine/test/classes/switch.rb +11 -0
  117. data/lib/branston/vendor/plugins/state_machine/test/functional/state_machine_test.rb +941 -0
  118. data/lib/branston/vendor/plugins/state_machine/test/test_helper.rb +4 -0
  119. data/lib/branston/vendor/plugins/state_machine/test/unit/assertions_test.rb +40 -0
  120. data/lib/branston/vendor/plugins/state_machine/test/unit/callback_test.rb +455 -0
  121. data/lib/branston/vendor/plugins/state_machine/test/unit/condition_proxy_test.rb +328 -0
  122. data/lib/branston/vendor/plugins/state_machine/test/unit/eval_helpers_test.rb +120 -0
  123. data/lib/branston/vendor/plugins/state_machine/test/unit/event_collection_test.rb +326 -0
  124. data/lib/branston/vendor/plugins/state_machine/test/unit/event_test.rb +743 -0
  125. data/lib/branston/vendor/plugins/state_machine/test/unit/guard_test.rb +908 -0
  126. data/lib/branston/vendor/plugins/state_machine/test/unit/integrations/active_record_test.rb +1367 -0
  127. data/lib/branston/vendor/plugins/state_machine/test/unit/integrations/data_mapper_test.rb +962 -0
  128. data/lib/branston/vendor/plugins/state_machine/test/unit/integrations/sequel_test.rb +859 -0
  129. data/lib/branston/vendor/plugins/state_machine/test/unit/integrations_test.rb +42 -0
  130. data/lib/branston/vendor/plugins/state_machine/test/unit/invalid_event_test.rb +7 -0
  131. data/lib/branston/vendor/plugins/state_machine/test/unit/invalid_transition_test.rb +7 -0
  132. data/lib/branston/vendor/plugins/state_machine/test/unit/machine_collection_test.rb +938 -0
  133. data/lib/branston/vendor/plugins/state_machine/test/unit/machine_test.rb +2004 -0
  134. data/lib/branston/vendor/plugins/state_machine/test/unit/matcher_helpers_test.rb +37 -0
  135. data/lib/branston/vendor/plugins/state_machine/test/unit/matcher_test.rb +155 -0
  136. data/lib/branston/vendor/plugins/state_machine/test/unit/node_collection_test.rb +207 -0
  137. data/lib/branston/vendor/plugins/state_machine/test/unit/state_collection_test.rb +280 -0
  138. data/lib/branston/vendor/plugins/state_machine/test/unit/state_machine_test.rb +31 -0
  139. data/lib/branston/vendor/plugins/state_machine/test/unit/state_test.rb +795 -0
  140. data/lib/branston/vendor/plugins/state_machine/test/unit/transition_test.rb +1212 -0
  141. metadata +81 -2
@@ -0,0 +1,326 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
+
3
+ class EventCollectionByDefaultTest < Test::Unit::TestCase
4
+ def setup
5
+ @machine = StateMachine::Machine.new(Class.new)
6
+ @events = StateMachine::EventCollection.new(@machine)
7
+ end
8
+
9
+ def test_should_not_have_any_nodes
10
+ assert_equal 0, @events.length
11
+ end
12
+
13
+ def test_should_have_a_machine
14
+ assert_equal @machine, @events.machine
15
+ end
16
+
17
+ def test_should_not_have_any_valid_events_for_an_object
18
+ assert @events.valid_for(@object).empty?
19
+ end
20
+
21
+ def test_should_not_have_any_transitions_for_an_object
22
+ assert @events.transitions_for(@object).empty?
23
+ end
24
+ end
25
+
26
+ class EventCollectionTest < Test::Unit::TestCase
27
+ def setup
28
+ machine = StateMachine::Machine.new(Class.new, :namespace => 'alarm')
29
+ @events = StateMachine::EventCollection.new(machine)
30
+
31
+ @events << @open = StateMachine::Event.new(machine, :enable)
32
+ end
33
+
34
+ def test_should_index_by_name
35
+ assert_equal @open, @events[:enable, :name]
36
+ end
37
+
38
+ def test_should_index_by_name_by_default
39
+ assert_equal @open, @events[:enable]
40
+ end
41
+
42
+ def test_should_index_by_qualified_name
43
+ assert_equal @open, @events[:enable_alarm, :qualified_name]
44
+ end
45
+ end
46
+
47
+ class EventCollectionWithEventsWithTransitionsTest < Test::Unit::TestCase
48
+ def setup
49
+ @klass = Class.new
50
+ @machine = StateMachine::Machine.new(@klass, :initial => :parked)
51
+ @events = StateMachine::EventCollection.new(@machine)
52
+
53
+ @machine.state :idling, :stalled
54
+ @machine.event :ignite
55
+
56
+ @events << @ignite = StateMachine::Event.new(@machine, :ignite)
57
+ @ignite.transition :parked => :idling
58
+ @ignite.transition :stalled => :idling
59
+ end
60
+
61
+ def test_should_only_include_valid_events_for_an_object
62
+ object = @klass.new
63
+ object.state = 'parked'
64
+ assert_equal [@ignite], @events.valid_for(object)
65
+
66
+ object.state = 'stalled'
67
+ assert_equal [@ignite], @events.valid_for(object)
68
+
69
+ object.state = 'idling'
70
+ assert_equal [], @events.valid_for(object)
71
+ end
72
+
73
+ def test_should_only_include_valid_transitions_for_an_object
74
+ object = @klass.new
75
+ object.state = 'parked'
76
+ assert_equal [{:object => object, :attribute => :state, :event => :ignite, :from => 'parked', :to => 'idling'}], @events.transitions_for(object).map {|transition| transition.attributes}
77
+
78
+ object.state = 'stalled'
79
+ assert_equal [{:object => object, :attribute => :state, :event => :ignite, :from => 'stalled', :to => 'idling'}], @events.transitions_for(object).map {|transition| transition.attributes}
80
+
81
+ object.state = 'idling'
82
+ assert_equal [], @events.transitions_for(object)
83
+ end
84
+
85
+ def test_should_filter_valid_transitions_for_an_object_if_requirements_specified
86
+ object = @klass.new
87
+ assert_equal [{:object => object, :attribute => :state, :event => :ignite, :from => 'stalled', :to => 'idling'}], @events.transitions_for(object, :from => :stalled).map {|transition| transition.attributes}
88
+ assert_equal [], @events.transitions_for(object, :from => :idling).map {|transition| transition.attributes}
89
+ end
90
+ end
91
+
92
+ class EventCollectionWithMultipleEventsTest < Test::Unit::TestCase
93
+ def setup
94
+ @klass = Class.new
95
+ @machine = StateMachine::Machine.new(@klass, :initial => :parked)
96
+ @events = StateMachine::EventCollection.new(@machine)
97
+
98
+ @machine.state :first_gear
99
+ @machine.event :park, :shift_down
100
+
101
+ @events << @park = StateMachine::Event.new(@machine, :park)
102
+ @park.transition :first_gear => :parked
103
+
104
+ @events << @shift_down = StateMachine::Event.new(@machine, :shift_down)
105
+ @shift_down.transition :first_gear => :parked
106
+ end
107
+
108
+ def test_should_only_include_all_valid_events_for_an_object
109
+ object = @klass.new
110
+ object.state = 'first_gear'
111
+ assert_equal [@park, @shift_down], @events.valid_for(object)
112
+ end
113
+ end
114
+
115
+ class EventCollectionWithoutMachineActionTest < Test::Unit::TestCase
116
+ def setup
117
+ @klass = Class.new
118
+ @machine = StateMachine::Machine.new(@klass, :initial => :parked)
119
+ @events = StateMachine::EventCollection.new(@machine)
120
+
121
+ @machine.event :ignite
122
+ @events << StateMachine::Event.new(@machine, :ignite)
123
+
124
+ @object = @klass.new
125
+ end
126
+
127
+ def test_should_not_have_an_attribute_transition
128
+ assert_nil @events.attribute_transition_for(@object)
129
+ end
130
+ end
131
+
132
+ class EventCollectionAttributeWithMachineActionTest < Test::Unit::TestCase
133
+ def setup
134
+ @klass = Class.new do
135
+ def save
136
+ end
137
+ end
138
+
139
+ @machine = StateMachine::Machine.new(@klass, :initial => :parked, :action => :save)
140
+ @events = StateMachine::EventCollection.new(@machine)
141
+
142
+ @machine.event :ignite
143
+ @machine.state :parked, :idling
144
+ @events << @ignite = StateMachine::Event.new(@machine, :ignite)
145
+
146
+ @object = @klass.new
147
+ end
148
+
149
+ def test_should_not_have_transition_if_nil
150
+ @object.state_event = nil
151
+ assert_nil @events.attribute_transition_for(@object)
152
+ end
153
+
154
+ def test_should_not_have_transition_if_empty
155
+ @object.state_event = ''
156
+ assert_nil @events.attribute_transition_for(@object)
157
+ end
158
+
159
+ def test_should_have_invalid_transition_if_invalid_event_specified
160
+ @object.state_event = 'invalid'
161
+ assert_equal false, @events.attribute_transition_for(@object)
162
+ end
163
+
164
+ def test_should_have_invalid_transition_if_event_cannot_be_fired
165
+ @object.state_event = 'ignite'
166
+ assert_equal false, @events.attribute_transition_for(@object)
167
+ end
168
+
169
+ def test_should_have_valid_transition_if_event_can_be_fired
170
+ @ignite.transition :parked => :idling
171
+ @object.state_event = 'ignite'
172
+
173
+ assert_instance_of StateMachine::Transition, @events.attribute_transition_for(@object)
174
+ end
175
+
176
+ def test_should_have_valid_transition_if_already_defined_in_transition_cache
177
+ @ignite.transition :parked => :idling
178
+ @object.state_event = nil
179
+ @object.send(:state_event_transition=, transition = @ignite.transition_for(@object))
180
+
181
+ assert_equal transition, @events.attribute_transition_for(@object)
182
+ end
183
+
184
+ def test_should_use_transition_cache_if_both_event_and_transition_are_present
185
+ @ignite.transition :parked => :idling
186
+ @object.state_event = 'ignite'
187
+ @object.send(:state_event_transition=, transition = @ignite.transition_for(@object))
188
+
189
+ assert_equal transition, @events.attribute_transition_for(@object)
190
+ end
191
+ end
192
+
193
+ class EventCollectionAttributeWithNamespacedMachineTest < Test::Unit::TestCase
194
+ def setup
195
+ @klass = Class.new do
196
+ def save
197
+ end
198
+ end
199
+
200
+ @machine = StateMachine::Machine.new(@klass, :namespace => 'alarm', :initial => :active, :action => :save)
201
+ @events = StateMachine::EventCollection.new(@machine)
202
+
203
+ @machine.event :disable
204
+ @machine.state :active, :off
205
+ @events << @disable = StateMachine::Event.new(@machine, :disable)
206
+
207
+ @object = @klass.new
208
+ end
209
+
210
+ def test_should_not_have_transition_if_nil
211
+ @object.state_event = nil
212
+ assert_nil @events.attribute_transition_for(@object)
213
+ end
214
+
215
+ def test_should_have_invalid_transition_if_event_cannot_be_fired
216
+ @object.state_event = 'disable'
217
+ assert_equal false, @events.attribute_transition_for(@object)
218
+ end
219
+
220
+ def test_should_have_valid_transition_if_event_can_be_fired
221
+ @disable.transition :active => :off
222
+ @object.state_event = 'disable'
223
+
224
+ assert_instance_of StateMachine::Transition, @events.attribute_transition_for(@object)
225
+ end
226
+ end
227
+
228
+ class EventCollectionWithValidationsTest < Test::Unit::TestCase
229
+ def setup
230
+ StateMachine::Integrations.const_set('Custom', Module.new do
231
+ def invalidate(object, attribute, message, values = [])
232
+ (object.errors ||= []) << generate_message(message, values)
233
+ end
234
+
235
+ def reset(object)
236
+ object.errors = []
237
+ end
238
+ end)
239
+
240
+ @klass = Class.new do
241
+ attr_accessor :errors
242
+
243
+ def initialize
244
+ @errors = []
245
+ super
246
+ end
247
+ end
248
+
249
+ @machine = StateMachine::Machine.new(@klass, :initial => :parked, :action => :save, :integration => :custom)
250
+ @events = StateMachine::EventCollection.new(@machine)
251
+
252
+ @machine.event :ignite
253
+ @machine.state :parked, :idling
254
+ @events << @ignite = StateMachine::Event.new(@machine, :ignite)
255
+
256
+ @object = @klass.new
257
+ end
258
+
259
+ def test_should_invalidate_if_invalid_event_specified
260
+ @object.state_event = 'invalid'
261
+ @events.attribute_transition_for(@object, true)
262
+
263
+ assert_equal ['is invalid'], @object.errors
264
+ end
265
+
266
+ def test_should_invalidate_if_event_cannot_be_fired
267
+ @object.state = 'idling'
268
+ @object.state_event = 'ignite'
269
+ @events.attribute_transition_for(@object, true)
270
+
271
+ assert_equal ['cannot transition when idling'], @object.errors
272
+ end
273
+
274
+ def test_should_invalidate_with_friendly_name_if_invalid_event_specified
275
+ # Add a valid nil state
276
+ @machine.state nil
277
+
278
+ @object.state = nil
279
+ @object.state_event = 'ignite'
280
+ @events.attribute_transition_for(@object, true)
281
+
282
+ assert_equal ['cannot transition when nil'], @object.errors
283
+ end
284
+
285
+ def test_should_not_invalidate_event_can_be_fired
286
+ @ignite.transition :parked => :idling
287
+ @object.state_event = 'ignite'
288
+ @events.attribute_transition_for(@object, true)
289
+
290
+ assert_equal [], @object.errors
291
+ end
292
+
293
+ def teardown
294
+ StateMachine::Integrations.send(:remove_const, 'Custom')
295
+ end
296
+ end
297
+
298
+ class EventCollectionWithCustomMachineAttributeTest < Test::Unit::TestCase
299
+ def setup
300
+ @klass = Class.new do
301
+ def save
302
+ end
303
+ end
304
+
305
+ @machine = StateMachine::Machine.new(@klass, :state, :attribute => :state_id, :initial => :parked, :action => :save)
306
+ @events = StateMachine::EventCollection.new(@machine)
307
+
308
+ @machine.event :ignite
309
+ @machine.state :parked, :idling
310
+ @events << @ignite = StateMachine::Event.new(@machine, :ignite)
311
+
312
+ @object = @klass.new
313
+ end
314
+
315
+ def test_should_not_have_transition_if_nil
316
+ @object.state_event = nil
317
+ assert_nil @events.attribute_transition_for(@object)
318
+ end
319
+
320
+ def test_should_have_valid_transition_if_event_can_be_fired
321
+ @ignite.transition :parked => :idling
322
+ @object.state_event = 'ignite'
323
+
324
+ assert_instance_of StateMachine::Transition, @events.attribute_transition_for(@object)
325
+ end
326
+ end