state_machines-activerecord 0.9.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +10 -2
  4. data/lib/state_machines/integrations/active_record/locale.rb +12 -9
  5. data/lib/state_machines/integrations/active_record/version.rb +3 -1
  6. data/lib/state_machines/integrations/active_record.rb +59 -102
  7. data/lib/state_machines-activerecord.rb +2 -0
  8. metadata +36 -142
  9. data/test/files/en.yml +0 -5
  10. data/test/files/models/post.rb +0 -11
  11. data/test/integration_test.rb +0 -25
  12. data/test/machine_by_default_test.rb +0 -16
  13. data/test/machine_errors_test.rb +0 -19
  14. data/test/machine_multiple_test.rb +0 -17
  15. data/test/machine_nested_action_test.rb +0 -38
  16. data/test/machine_unmigrated_test.rb +0 -14
  17. data/test/machine_with_aliased_attribute_test.rb +0 -23
  18. data/test/machine_with_callbacks_test.rb +0 -172
  19. data/test/machine_with_column_state_attribute_test.rb +0 -44
  20. data/test/machine_with_complex_pluralization_scopes_test.rb +0 -16
  21. data/test/machine_with_conflicting_predicate_test.rb +0 -18
  22. data/test/machine_with_conflicting_state_name_test.rb +0 -29
  23. data/test/machine_with_custom_attribute_test.rb +0 -21
  24. data/test/machine_with_default_scope_test.rb +0 -18
  25. data/test/machine_with_different_column_default_test.rb +0 -27
  26. data/test/machine_with_different_integer_column_default_test.rb +0 -29
  27. data/test/machine_with_dirty_attribute_and_custom_attributes_during_loopback_test.rb +0 -24
  28. data/test/machine_with_dirty_attribute_and_state_events_test.rb +0 -20
  29. data/test/machine_with_dirty_attributes_and_custom_attribute_test.rb +0 -32
  30. data/test/machine_with_dirty_attributes_during_loopback_test.rb +0 -22
  31. data/test/machine_with_dirty_attributes_test.rb +0 -35
  32. data/test/machine_with_dynamic_initial_state_test.rb +0 -99
  33. data/test/machine_with_event_attributes_on_autosave_test.rb +0 -48
  34. data/test/machine_with_event_attributes_on_custom_action_test.rb +0 -41
  35. data/test/machine_with_event_attributes_on_save_bang_test.rb +0 -82
  36. data/test/machine_with_event_attributes_on_save_test.rb +0 -244
  37. data/test/machine_with_event_attributes_on_validation_test.rb +0 -143
  38. data/test/machine_with_events_test.rb +0 -13
  39. data/test/machine_with_failed_action_test.rb +0 -40
  40. data/test/machine_with_failed_after_callbacks_test.rb +0 -35
  41. data/test/machine_with_failed_before_callbacks_test.rb +0 -36
  42. data/test/machine_with_initialized_state_test.rb +0 -41
  43. data/test/machine_with_internationalization_test.rb +0 -180
  44. data/test/machine_with_loopback_test.rb +0 -22
  45. data/test/machine_with_non_column_state_attribute_defined_test.rb +0 -29
  46. data/test/machine_with_same_column_default_test.rb +0 -26
  47. data/test/machine_with_same_integer_column_default_test.rb +0 -30
  48. data/test/machine_with_scopes_and_joins_test.rb +0 -38
  49. data/test/machine_with_scopes_and_owner_subclass_test.rb +0 -27
  50. data/test/machine_with_scopes_test.rb +0 -70
  51. data/test/machine_with_state_driven_validations_test.rb +0 -30
  52. data/test/machine_with_states_test.rb +0 -13
  53. data/test/machine_with_static_initial_state_test.rb +0 -167
  54. data/test/machine_with_transactions_test.rb +0 -26
  55. data/test/machine_with_validations_and_custom_attribute_test.rb +0 -21
  56. data/test/machine_with_validations_test.rb +0 -47
  57. data/test/machine_without_database_test.rb +0 -20
  58. data/test/machine_without_transactions_test.rb +0 -26
  59. data/test/model_test.rb +0 -12
  60. data/test/test_helper.rb +0 -58
@@ -1,35 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- class MachineWithDirtyAttributesTest < BaseTestCase
4
- def setup
5
- @model = new_model
6
- @machine = StateMachines::Machine.new(@model, :initial => :parked)
7
- @machine.event :ignite
8
- @machine.state :idling
9
-
10
- @record = @model.create
11
-
12
- @transition = StateMachines::Transition.new(@record, @machine, :ignite, :parked, :idling)
13
- @transition.perform(false)
14
- end
15
-
16
- def test_should_include_state_in_changed_attributes
17
- assert_equal %w(state), @record.changed
18
- end
19
-
20
- def test_should_track_attribute_change
21
- assert_equal %w(parked idling), @record.changes['state']
22
- end
23
-
24
- def test_should_not_reset_changes_on_multiple_transitions
25
- transition = StateMachines::Transition.new(@record, @machine, :ignite, :idling, :idling)
26
- transition.perform(false)
27
-
28
- assert_equal %w(parked idling), @record.changes['state']
29
- end
30
-
31
- def test_should_not_have_changes_when_loaded_from_database
32
- record = @model.find(@record.id)
33
- refute record.changed?
34
- end
35
- end
@@ -1,99 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- class MachineWithDynamicInitialStateTest < BaseTestCase
4
- def setup
5
- @model = new_model do
6
- attr_accessor :value
7
- end
8
- @machine = StateMachines::Machine.new(@model, :initial => lambda { |object| :parked })
9
- @machine.state :parked
10
- end
11
-
12
- def test_should_set_initial_state_on_created_object
13
- record = @model.new
14
- assert_equal 'parked', record.state
15
- end
16
-
17
- def test_should_still_set_attributes
18
- record = @model.new(:value => 1)
19
- assert_equal 1, record.value
20
- end
21
-
22
- def test_should_still_allow_initialize_blocks
23
- block_args = nil
24
- record = @model.new do |*args|
25
- block_args = args
26
- end
27
-
28
- assert_equal [record], block_args
29
- end
30
-
31
- def test_should_set_attributes_prior_to_initialize_block
32
- state = nil
33
- @model.new do |record|
34
- state = record.state
35
- end
36
-
37
- assert_equal 'parked', state
38
- end
39
-
40
- def test_should_set_attributes_prior_to_after_initialize_hook
41
- state = nil
42
- @model.after_initialize do |record|
43
- state = record.state
44
- end
45
- @model.new
46
- assert_equal 'parked', state
47
- end
48
-
49
- def test_should_set_initial_state_after_setting_attributes
50
- @model.class_eval do
51
- attr_accessor :state_during_setter
52
-
53
- remove_method :value=
54
- define_method(:value=) do |value|
55
- self.state_during_setter = state || 'nil'
56
- end
57
- end
58
-
59
- record = @model.new(:value => 1)
60
- assert_equal 'nil', record.state_during_setter
61
- end
62
-
63
- def test_should_not_set_initial_state_after_already_initialized
64
- record = @model.new(:value => 1)
65
- assert_equal 'parked', record.state
66
-
67
- record.state = 'idling'
68
- record.attributes = {}
69
- assert_equal 'idling', record.state
70
- end
71
-
72
- def test_should_persist_initial_state
73
- record = @model.new
74
- record.save
75
- record.reload
76
- assert_equal 'parked', record.state
77
- end
78
-
79
- def test_should_persist_initial_state_on_dup
80
- record = @model.create.dup
81
- record.save
82
- record.reload
83
- assert_equal 'parked', record.state
84
- end
85
-
86
- def test_should_use_stored_values_when_loading_from_database
87
- @machine.state :idling
88
-
89
- record = @model.find(@model.create(:state => 'idling').id)
90
- assert_equal 'idling', record.state
91
- end
92
-
93
- def test_should_use_stored_values_when_loading_from_database_with_nil_state
94
- @machine.state nil
95
-
96
- record = @model.find(@model.create(:state => nil).id)
97
- assert_nil record.state
98
- end
99
- end
@@ -1,48 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- class MachineWithEventAttributesOnAutosaveTest < BaseTestCase
4
- def setup
5
- @vehicle_model = new_model(:vehicle) do
6
- connection.add_column table_name, :owner_id, :integer
7
- end
8
- MachineWithEventAttributesOnAutosaveTest.const_set('Vehicle', @vehicle_model)
9
-
10
- @owner_model = new_model(:owner)
11
- MachineWithEventAttributesOnAutosaveTest.const_set('Owner', @owner_model)
12
-
13
- machine = StateMachines::Machine.new(@vehicle_model)
14
- machine.event :ignite do
15
- transition :parked => :idling
16
- end
17
-
18
- @owner = @owner_model.create
19
- @vehicle = @vehicle_model.create(:state => 'parked', :owner_id => @owner.id)
20
- end
21
-
22
- def test_should_persist_has_one_autosave
23
- @owner_model.has_one :vehicle, :class_name => 'MachineWithEventAttributesOnAutosaveTest::Vehicle', :autosave => true
24
- @owner.vehicle.state_event = 'ignite'
25
- @owner.save
26
-
27
- @vehicle.reload
28
- assert_equal 'idling', @vehicle.state
29
- end
30
-
31
- def test_should_persist_has_many_autosave
32
- @owner_model.has_many :vehicles, :class_name => 'MachineWithEventAttributesOnAutosaveTest::Vehicle', :autosave => true
33
- @owner.vehicles[0].state_event = 'ignite'
34
- @owner.save
35
-
36
- @vehicle.reload
37
- assert_equal 'idling', @vehicle.state
38
- end
39
-
40
- def teardown
41
- MachineWithEventAttributesOnAutosaveTest.class_eval do
42
- remove_const('Vehicle')
43
- remove_const('Owner')
44
- end
45
- clear_active_support_dependencies
46
- super
47
- end
48
- end
@@ -1,41 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- class MachineWithEventAttributesOnCustomActionTest < BaseTestCase
4
- def setup
5
- @superclass = new_model do
6
- def persist
7
- create_or_update
8
- end
9
- end
10
- @model = Class.new(@superclass)
11
- @machine = StateMachines::Machine.new(@model, :action => :persist)
12
- @machine.event :ignite do
13
- transition :parked => :idling
14
- end
15
-
16
- @record = @model.new
17
- @record.state = 'parked'
18
- @record.state_event = 'ignite'
19
- end
20
-
21
- def test_should_not_transition_on_valid?
22
- @record.valid?
23
- assert_equal 'parked', @record.state
24
- end
25
-
26
- def test_should_not_transition_on_save
27
- @record.save
28
- assert_equal 'parked', @record.state
29
- end
30
-
31
- def test_should_not_transition_on_save!
32
- @record.save!
33
- assert_equal 'parked', @record.state
34
- end
35
-
36
- def test_should_transition_on_custom_action
37
- @record.persist
38
- assert_equal 'idling', @record.state
39
- end
40
- end
41
-
@@ -1,82 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- class MachineWithEventAttributesOnSaveBangTest < BaseTestCase
4
- def setup
5
- @model = new_model
6
- @machine = StateMachines::Machine.new(@model)
7
- @machine.event :ignite do
8
- transition :parked => :idling
9
- end
10
-
11
- @record = @model.new
12
- @record.state = 'parked'
13
- @record.state_event = 'ignite'
14
- end
15
-
16
- def test_should_fail_if_event_is_invalid
17
- @record.state_event = 'invalid'
18
- assert_raise(ActiveRecord::RecordInvalid) { @record.save! }
19
- end
20
-
21
- def test_should_fail_if_event_has_no_transition
22
- @record.state = 'idling'
23
- assert_raise(ActiveRecord::RecordInvalid) { @record.save! }
24
- end
25
-
26
- def test_should_be_successful_if_event_has_transition
27
- assert_equal true, @record.save!
28
- end
29
-
30
- def test_should_run_before_callbacks
31
- ran_callback = false
32
- @machine.before_transition { ran_callback = true }
33
-
34
- @record.save!
35
- assert ran_callback
36
- end
37
-
38
- def test_should_run_before_callbacks_once
39
- before_count = 0
40
- @machine.before_transition { before_count += 1 }
41
-
42
- @record.save!
43
- assert_equal 1, before_count
44
- end
45
-
46
- def test_should_run_around_callbacks_before_yield
47
- ran_callback = false
48
- @machine.around_transition { |block| ran_callback = true; block.call }
49
-
50
- @record.save!
51
- assert ran_callback
52
- end
53
-
54
- def test_should_run_around_callbacks_before_yield_once
55
- around_before_count = 0
56
- @machine.around_transition { |block| around_before_count += 1; block.call }
57
-
58
- @record.save!
59
- assert_equal 1, around_before_count
60
- end
61
-
62
- def test_should_persist_new_state
63
- @record.save!
64
- assert_equal 'idling', @record.state
65
- end
66
-
67
- def test_should_run_after_callbacks
68
- ran_callback = false
69
- @machine.after_transition { ran_callback = true }
70
-
71
- @record.save!
72
- assert ran_callback
73
- end
74
-
75
- def test_should_run_around_callbacks_after_yield
76
- ran_callback = false
77
- @machine.around_transition { |block| block.call; ran_callback = true }
78
-
79
- @record.save!
80
- assert ran_callback
81
- end
82
- end
@@ -1,244 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- class MachineWithEventAttributesOnSaveTest < BaseTestCase
4
- def setup
5
- @model = new_model
6
- @machine = StateMachines::Machine.new(@model)
7
- @machine.event :ignite do
8
- transition :parked => :idling
9
- end
10
-
11
- @record = @model.new
12
- @record.state = 'parked'
13
- @record.state_event = 'ignite'
14
- end
15
-
16
- def test_should_fail_if_event_is_invalid
17
- @record.state_event = 'invalid'
18
- assert_equal false, @record.save
19
- end
20
-
21
- def test_should_fail_if_event_has_no_transition
22
- @record.state = 'idling'
23
- assert_equal false, @record.save
24
- end
25
-
26
- def test_should_run_before_callbacks
27
- ran_callback = false
28
- @machine.before_transition { ran_callback = true }
29
-
30
- @record.save
31
- assert ran_callback
32
- end
33
-
34
- def test_should_run_before_callbacks_once
35
- before_count = 0
36
- @machine.before_transition { before_count += 1 }
37
-
38
- @record.save
39
- assert_equal 1, before_count
40
- end
41
-
42
- def test_should_run_around_callbacks_before_yield
43
- ran_callback = false
44
- @machine.around_transition { |block| ran_callback = true; block.call }
45
-
46
- @record.save
47
- assert ran_callback
48
- end
49
-
50
- def test_should_run_around_callbacks_before_yield_once
51
- around_before_count = 0
52
- @machine.around_transition { |block| around_before_count += 1; block.call }
53
-
54
- @record.save
55
- assert_equal 1, around_before_count
56
- end
57
-
58
- def test_should_persist_new_state
59
- @record.save
60
- assert_equal 'idling', @record.state
61
- end
62
-
63
- def test_should_run_after_callbacks
64
- ran_callback = false
65
- @machine.after_transition { ran_callback = true }
66
-
67
- @record.save
68
- assert ran_callback
69
- end
70
-
71
- def test_should_not_run_after_callbacks_with_failures_disabled_if_fails
72
- @model.before_create { |record| abort_from_callback }
73
-
74
- ran_callback = false
75
- @machine.after_transition { ran_callback = true }
76
-
77
- begin
78
- ; @record.save;
79
- rescue;
80
- end
81
- refute ran_callback
82
- end
83
-
84
- def test_should_run_failure_callbacks__if_fails
85
- @model.before_create { |record| abort_from_callback }
86
-
87
- ran_callback = false
88
- @machine.after_failure { ran_callback = true }
89
-
90
- begin
91
- ; @record.save;
92
- rescue;
93
- end
94
- assert ran_callback
95
- end
96
-
97
- def test_should_not_run_around_callbacks_if_fails
98
- @model.before_create { |record| abort_from_callback }
99
-
100
- ran_callback = false
101
- @machine.around_transition { |block| block.call; ran_callback = true }
102
-
103
- begin
104
- ; @record.save;
105
- rescue;
106
- end
107
- refute ran_callback
108
- end
109
-
110
- def test_should_run_around_callbacks_after_yield
111
- ran_callback = false
112
- @machine.around_transition { |block| block.call; ran_callback = true }
113
-
114
- @record.save
115
- assert ran_callback
116
- end
117
-
118
- def test_should_run_before_transitions_within_transaction
119
- @machine.before_transition { @model.create; raise ActiveRecord::Rollback }
120
-
121
- begin
122
- @record.save
123
- rescue Exception
124
- end
125
-
126
- assert_equal 0, @model.count
127
- end
128
-
129
- def test_should_run_after_transitions_within_transaction
130
- @machine.after_transition { @model.create; raise ActiveRecord::Rollback }
131
-
132
- begin
133
- @record.save
134
- rescue Exception
135
- end
136
-
137
- assert_equal 0, @model.count
138
- end
139
-
140
- def test_should_run_around_transition_within_transaction
141
- @machine.around_transition { @model.create; raise ActiveRecord::Rollback }
142
-
143
- begin
144
- @record.save
145
- rescue Exception
146
- end
147
-
148
- assert_equal 0, @model.count
149
- end
150
-
151
- def test_should_allow_additional_transitions_to_new_state_in_after_transitions
152
- @machine.event :park do
153
- transition :idling => :parked
154
- end
155
-
156
- @machine.after_transition(:on => :ignite) { @record.park }
157
-
158
- @record.save
159
- assert_equal 'parked', @record.state
160
-
161
- @record.reload
162
- assert_equal 'parked', @record.state
163
- end
164
-
165
- def test_should_allow_additional_transitions_to_previous_state_in_after_transitions
166
- @machine.event :shift_up do
167
- transition :idling => :first_gear
168
- end
169
-
170
- @machine.after_transition(:on => :ignite) { @record.shift_up }
171
-
172
- @record.save
173
- assert_equal 'first_gear', @record.state
174
-
175
- @record.reload
176
- assert_equal 'first_gear', @record.state
177
- end
178
-
179
- def test_should_yield_one_model!
180
- assert_equal true, @record.save!
181
- assert_equal 1, @model.count
182
- end
183
-
184
- # explicit tests of #save and #save! to ensure expected behavior
185
- def test_should_yield_two_models_with_before
186
- @machine.before_transition { @model.create! }
187
- assert_equal true, @record.save
188
- assert_equal 2, @model.count
189
- end
190
-
191
- def test_should_yield_two_models_with_before!
192
- @machine.before_transition { @model.create! }
193
- assert_equal true, @record.save!
194
- assert_equal 2, @model.count
195
- end
196
-
197
- def test_should_raise_on_around_transition_rollback!
198
- @machine.before_transition { @model.create! }
199
- @machine.around_transition { @model.create!; raise ActiveRecord::Rollback }
200
-
201
- raised = false
202
- begin
203
- @record.save!
204
- rescue Exception
205
- raised = true
206
- end
207
-
208
- assert_equal true, raised
209
- assert_equal 0, @model.count
210
- end
211
-
212
- def test_should_return_nil_on_around_transition_rollback
213
- @machine.before_transition { @model.create! }
214
- @machine.around_transition { @model.create!; raise ActiveRecord::Rollback }
215
- assert_nil @record.save
216
- assert_equal 0, @model.count
217
- end
218
-
219
- def test_should_return_nil_on_before_transition_rollback
220
- @machine.before_transition { raise ActiveRecord::Rollback }
221
- assert_nil @record.save
222
- assert_equal 0, @model.count
223
- end
224
-
225
- #
226
- # @rosskevin - This fails and I'm not sure why, it was existing behavior.
227
- # see: https://github.com/state-machines/state_machines-activerecord/pull/26#issuecomment-112911886
228
- #
229
- # def test_should_yield_three_models_with_before_and_around_save
230
- # @machine.before_transition { @model.create!; puts "before ran, now #{@model.count}" }
231
- # @machine.around_transition { @model.create!; puts "around ran, now #{@model.count}" }
232
- #
233
- # assert_equal true, @record.save
234
- # assert_equal 3, @model.count
235
- # end
236
- #
237
- # def test_should_yield_three_models_with_before_and_around_save!
238
- # @machine.before_transition { @model.create!; puts "before ran, now #{@model.count}" }
239
- # @machine.around_transition { @model.create!; puts "around ran, now #{@model.count}" }
240
- #
241
- # assert_equal true, @record.save!
242
- # assert_equal 3, @model.count
243
- # end
244
- end
@@ -1,143 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- class MachineWithEventAttributesOnValidationTest < BaseTestCase
4
- def setup
5
- @model = new_model
6
- @machine = StateMachines::Machine.new(@model)
7
- @machine.event :ignite do
8
- transition :parked => :idling
9
- end
10
-
11
- @record = @model.new
12
- @record.state = 'parked'
13
- @record.state_event = 'ignite'
14
- end
15
-
16
- def test_should_fail_if_event_is_invalid
17
- @record.state_event = 'invalid'
18
- refute @record.valid?
19
- assert_equal ['State event is invalid'], @record.errors.full_messages
20
- end
21
-
22
- def test_should_fail_if_event_has_no_transition
23
- @record.state = 'idling'
24
- refute @record.valid?
25
- assert_equal ['State event cannot transition when idling'], @record.errors.full_messages
26
- end
27
-
28
- def test_should_be_successful_if_event_has_transition
29
- assert @record.valid?
30
- end
31
-
32
- def test_should_run_before_callbacks
33
- ran_callback = false
34
- @machine.before_transition { ran_callback = true }
35
-
36
- @record.valid?
37
- assert ran_callback
38
- end
39
-
40
- def test_should_run_around_callbacks_before_yield
41
- ran_callback = false
42
- @machine.around_transition { |block| ran_callback = true; block.call }
43
-
44
- begin
45
- @record.valid?
46
- rescue ArgumentError
47
- raise if StateMachines::Transition.pause_supported?
48
- end
49
- assert ran_callback
50
- end
51
-
52
- def test_should_persist_new_state
53
- @record.valid?
54
- assert_equal 'idling', @record.state
55
- end
56
-
57
- def test_should_not_run_after_callbacks
58
- ran_callback = false
59
- @machine.after_transition { ran_callback = true }
60
-
61
- @record.valid?
62
- refute ran_callback
63
- end
64
-
65
- def test_should_not_run_after_callbacks_with_failures_disabled_if_validation_fails
66
- @model.class_eval do
67
- attr_accessor :seatbelt
68
- validates :seatbelt, presence: true
69
- end
70
-
71
- ran_callback = false
72
- @machine.after_transition { ran_callback = true }
73
-
74
- @record.valid?
75
- refute ran_callback
76
- end
77
-
78
- def test_should_run_after_callbacks_if_validation_fails
79
- @model.class_eval do
80
- attr_accessor :seatbelt
81
- validates :seatbelt, presence: true
82
- end
83
-
84
- ran_callback = false
85
- @machine.after_failure { ran_callback = true }
86
-
87
- @record.valid?
88
- assert ran_callback
89
- end
90
-
91
- def test_should_not_run_around_callbacks_after_yield
92
- ran_callback = false
93
- @machine.around_transition { |block| block.call; ran_callback = true }
94
-
95
- begin
96
- @record.valid?
97
- rescue ArgumentError
98
- raise if StateMachines::Transition.pause_supported?
99
- end
100
- refute ran_callback
101
- end
102
-
103
- def test_should_not_run_around_callbacks_after_yield_with_failures_disabled_if_validation_fails
104
- @model.class_eval do
105
- attr_accessor :seatbelt
106
- validates :seatbelt, presence: true
107
- end
108
-
109
- ran_callback = false
110
- @machine.around_transition { |block| block.call; ran_callback = true }
111
-
112
- @record.valid?
113
- refute ran_callback
114
- end
115
-
116
- def test_should_rollback_before_transitions_with_raise
117
- @machine.before_transition {
118
- @model.create;
119
- raise ActiveRecord::Rollback
120
- }
121
-
122
- begin
123
- @record.valid?
124
- rescue Exception
125
- end
126
-
127
- assert_equal 0, @model.count
128
- end
129
-
130
- def test_should_rollback_before_transitions_with_false
131
- @machine.before_transition {
132
- @model.create;
133
- false
134
- }
135
-
136
- begin
137
- @record.valid?
138
- rescue Exception
139
- end
140
-
141
- assert_equal 0, @model.count
142
- end
143
- end
@@ -1,13 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- class MachineWithEventsTest < BaseTestCase
4
- def setup
5
- @model = new_model
6
- @machine = StateMachines::Machine.new(@model)
7
- @machine.event :shift_up
8
- end
9
-
10
- def test_should_humanize_name
11
- assert_equal 'shift up', @machine.event(:shift_up).human_name
12
- end
13
- end