state_machines-activerecord 0.8.0 → 0.10.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 (71) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +5 -6
  4. data/lib/state_machines/integrations/active_record/locale.rb +2 -0
  5. data/lib/state_machines/integrations/active_record/version.rb +3 -1
  6. data/lib/state_machines/integrations/active_record.rb +42 -151
  7. data/lib/state_machines-activerecord.rb +2 -0
  8. data/test/files/models/post.rb +2 -0
  9. data/test/integration_test.rb +2 -0
  10. data/test/machine_by_default_test.rb +2 -0
  11. data/test/machine_errors_test.rb +2 -0
  12. data/test/machine_multiple_test.rb +2 -0
  13. data/test/machine_nested_action_test.rb +2 -0
  14. data/test/machine_unmigrated_test.rb +2 -0
  15. data/test/machine_with_aliased_attribute_test.rb +2 -0
  16. data/test/machine_with_callbacks_test.rb +2 -0
  17. data/test/machine_with_column_state_attribute_test.rb +2 -0
  18. data/test/machine_with_complex_pluralization_scopes_test.rb +2 -0
  19. data/test/machine_with_conflicting_predicate_test.rb +2 -0
  20. data/test/machine_with_conflicting_state_name_test.rb +4 -2
  21. data/test/machine_with_custom_attribute_test.rb +2 -0
  22. data/test/machine_with_default_scope_test.rb +2 -0
  23. data/test/machine_with_different_column_default_test.rb +2 -0
  24. data/test/machine_with_different_integer_column_default_test.rb +2 -0
  25. data/test/machine_with_dirty_attribute_and_custom_attributes_during_loopback_test.rb +2 -0
  26. data/test/machine_with_dirty_attribute_and_state_events_test.rb +2 -0
  27. data/test/machine_with_dirty_attributes_and_custom_attribute_test.rb +2 -0
  28. data/test/machine_with_dirty_attributes_during_loopback_test.rb +2 -0
  29. data/test/machine_with_dirty_attributes_test.rb +2 -0
  30. data/test/machine_with_dynamic_initial_state_test.rb +2 -0
  31. data/test/machine_with_event_attributes_on_autosave_test.rb +3 -1
  32. data/test/machine_with_event_attributes_on_custom_action_test.rb +2 -0
  33. data/test/machine_with_event_attributes_on_save_bang_test.rb +2 -0
  34. data/test/machine_with_event_attributes_on_save_test.rb +2 -0
  35. data/test/machine_with_event_attributes_on_validation_test.rb +5 -3
  36. data/test/machine_with_events_test.rb +2 -0
  37. data/test/machine_with_failed_action_test.rb +2 -0
  38. data/test/machine_with_failed_after_callbacks_test.rb +2 -0
  39. data/test/machine_with_failed_before_callbacks_test.rb +2 -0
  40. data/test/machine_with_initialized_state_test.rb +2 -0
  41. data/test/machine_with_internationalization_test.rb +2 -0
  42. data/test/machine_with_loopback_test.rb +2 -0
  43. data/test/machine_with_non_column_state_attribute_defined_test.rb +2 -0
  44. data/test/machine_with_same_column_default_test.rb +2 -0
  45. data/test/machine_with_same_integer_column_default_test.rb +2 -0
  46. data/test/machine_with_scopes_and_joins_test.rb +4 -1
  47. data/test/machine_with_scopes_and_owner_subclass_test.rb +2 -0
  48. data/test/machine_with_scopes_test.rb +2 -0
  49. data/test/machine_with_state_driven_validations_test.rb +3 -1
  50. data/test/machine_with_states_test.rb +2 -0
  51. data/test/machine_with_static_initial_state_test.rb +4 -1
  52. data/test/machine_with_transactions_test.rb +2 -0
  53. data/test/machine_with_validations_and_custom_attribute_test.rb +2 -0
  54. data/test/machine_with_validations_test.rb +2 -0
  55. data/test/machine_without_database_test.rb +2 -0
  56. data/test/machine_without_transactions_test.rb +2 -0
  57. data/test/model_test.rb +2 -0
  58. data/test/test_helper.rb +21 -16
  59. metadata +8 -23
  60. data/.gitignore +0 -22
  61. data/.travis.yml +0 -19
  62. data/Appraisals +0 -34
  63. data/Gemfile +0 -6
  64. data/Rakefile +0 -9
  65. data/gemfiles/active_record_5.1.gemfile +0 -14
  66. data/gemfiles/active_record_5.2.gemfile +0 -14
  67. data/gemfiles/active_record_6.0.gemfile +0 -14
  68. data/gemfiles/active_record_6.1.gemfile +0 -14
  69. data/gemfiles/active_record_edge.gemfile +0 -14
  70. data/log/.gitkeep +0 -0
  71. data/state_machines-activerecord.gemspec +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4d6c3db18b13bbece06c33f047109e49d17eb1b97e8d26d8e001ed02a554b7a
4
- data.tar.gz: ebd085709c837eb3c76994e23780b884136a338f92b63eb77c8c64620bd1980e
3
+ metadata.gz: a5e8b447b65a1f99ad367425556a3e726b3f42be5056af03a2a48e741851ff72
4
+ data.tar.gz: 801a7943d18a71f506acefedb764cb8ed0a9caa1c459893df99f3b21419c78f7
5
5
  SHA512:
6
- metadata.gz: febb1df5b304114be86875716fb620b7c1b7fe1d0d44bea3c52c92451345e2cf2fb57e11cbd87d9b277079a52ebb9f82734d4174ea6722e8c6d933d274f88f6d
7
- data.tar.gz: 3ee22472203164647a9d65ef4a5df8edfeda3874144b57281b9dce79ae210006f171bc02fdcdd24d44afd08ed4b9dff409b61d443a61052a1baeee27d8f3ed16
6
+ metadata.gz: c6794e0f3d9e6835682f4a541bb8bde8210599749621c262ed164bae482c78f3ec40aa6cc4279db5ed62583bd5d2f30476f43f49f5adc149ac80eb9df20ee487
7
+ data.tar.gz: 0fc0b42cc6de4c17f4a844634647dd0e0245933c6a713cf51e68655b4354e03801b0a6b63e61c1e27298a1db56ae8559a605972e2a6ef3cc879f32f75691c3b6
data/LICENSE.txt CHANGED
@@ -1,5 +1,5 @@
1
1
  Copyright (c) 2006-2012 Aaron Pfeifer
2
- Copyright (c) 2014-2021 Abdelkader Boudih
2
+ Copyright (c) 2014-2025 Abdelkader Boudih
3
3
 
4
4
  MIT License
5
5
 
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
- [![Build Status](https://travis-ci.com/state-machines/state_machines-activerecord.svg?branch=master)](https://travis-ci.com/state-machines/state_machines-activerecord)
2
- [![Code Climate](https://codeclimate.com/github/state-machines/state_machines-activerecord.svg)](https://codeclimate.com/github/state-machines/state_machines-activerecord)
1
+ [![Build Status](https://github.com/state-machines/state_machines-activerecord/actions/workflows/ruby.yml/badge.svg)](https://github.com/state-machines/state_machines-activerecord/actions/workflows/ruby.yml)
3
2
 
4
3
  # StateMachines Active Record Integration
5
4
 
@@ -27,7 +26,7 @@ For the complete usage guide, see http://www.rubydoc.info/github/state-machines/
27
26
  ### Example
28
27
 
29
28
  ```ruby
30
- class Vehicle < ActiveRecord::Base
29
+ class Vehicle < ApplicationRecord
31
30
  state_machine :initial => :parked do
32
31
  before_transition :parked => any - :parked, :do => :put_on_seatbelt
33
32
  after_transition any => :parked do |vehicle, transition|
@@ -40,7 +39,7 @@ class Vehicle < ActiveRecord::Base
40
39
  end
41
40
 
42
41
  state :first_gear, :second_gear do
43
- validates_presence_of :seatbelt_on
42
+ validates :seatbelt_on, presence: true
44
43
  end
45
44
  end
46
45
 
@@ -73,7 +72,7 @@ framework, custom validators will not work as expected when defined to run
73
72
  in multiple states. For example:
74
73
 
75
74
  ```ruby
76
- class Vehicle < ActiveRecord::Base
75
+ class Vehicle < ApplicationRecord
77
76
  state_machine do
78
77
  state :first_gear, :second_gear do
79
78
  validate :speed_is_legal
@@ -87,7 +86,7 @@ for the <tt>:second_gear</tt> state. To avoid this, you can define your
87
86
  custom validation like so:
88
87
 
89
88
  ```ruby
90
- class Vehicle < ActiveRecord::Base
89
+ class Vehicle < ApplicationRecord
91
90
  state_machine do
92
91
  state :first_gear, :second_gear do
93
92
  validate {|vehicle| vehicle.speed_is_legal}
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  { en: {
2
4
  activerecord: {
3
5
  errors: {
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module StateMachines
2
4
  module Integrations
3
5
  module ActiveRecord
4
- VERSION = '0.8.0'
6
+ VERSION = '0.10.0'
5
7
  end
6
8
  end
7
9
  end
@@ -11,7 +11,7 @@ module StateMachines
11
11
  # Below is an example of a simple state machine defined within an
12
12
  # ActiveRecord model:
13
13
  #
14
- # class Vehicle < ActiveRecord::Base
14
+ # class Vehicle < ApplicationRecord
15
15
  # state_machine :initial => :parked do
16
16
  # event :ignite do
17
17
  # transition :parked => :idling
@@ -78,25 +78,22 @@ module StateMachines
78
78
  # === Security implications
79
79
  #
80
80
  # Beware that public event attributes mean that events can be fired
81
- # whenever mass-assignment is being used. If you want to prevent malicious
82
- # users from tampering with events through URLs / forms, the attribute
83
- # should be protected like so:
84
- #
85
- # class Vehicle < ActiveRecord::Base
86
- # attr_protected :state_event
87
- # # attr_accessible ... # Alternative technique
88
- #
89
- # state_machine do
90
- # ...
81
+ # whenever mass-assignment is being used. If you want to prevent malicious
82
+ # users from tampering with events through URLs / forms, you should use
83
+ # Rails' strong parameters to control which attributes are permitted:
84
+ #
85
+ # class VehiclesController < ApplicationController
86
+ # def vehicle_params
87
+ # params.require(:vehicle).permit(:color, :make, :model)
88
+ # # Exclude state_event to prevent tampering
91
89
  # end
92
90
  # end
93
91
  #
94
92
  # If you want to only have *some* events be able to fire via mass-assignment,
95
93
  # you can build two state machines (one public and one protected) like so:
96
94
  #
97
- # class Vehicle < ActiveRecord::Base
98
- # attr_protected :state_event # Prevent access to events in the first machine
99
- #
95
+ # class Vehicle < ApplicationRecord
96
+ # # Define private machine
100
97
  # state_machine do
101
98
  # # Define private events here
102
99
  # end
@@ -105,6 +102,8 @@ module StateMachines
105
102
  # state_machine :public_state, :attribute => :state do
106
103
  # # Define public events here
107
104
  # end
105
+ #
106
+ # # Control access via strong parameters in your controller
108
107
  # end
109
108
  #
110
109
  # == Transactions
@@ -115,7 +114,7 @@ module StateMachines
115
114
  #
116
115
  # For example,
117
116
  #
118
- # class Message < ActiveRecord::Base
117
+ # class Message < ApplicationRecord
119
118
  # end
120
119
  #
121
120
  # Vehicle.state_machine do
@@ -136,7 +135,7 @@ module StateMachines
136
135
  #
137
136
  # To turn off transactions:
138
137
  #
139
- # class Vehicle < ActiveRecord::Base
138
+ # class Vehicle < ApplicationRecord
140
139
  # state_machine :initial => :parked, :use_transactions => false do
141
140
  # ...
142
141
  # end
@@ -150,7 +149,7 @@ module StateMachines
150
149
  # framework, custom validators will not work as expected when defined to run
151
150
  # in multiple states. For example:
152
151
  #
153
- # class Vehicle < ActiveRecord::Base
152
+ # class Vehicle < ApplicationRecord
154
153
  # state_machine do
155
154
  # ...
156
155
  # state :first_gear, :second_gear do
@@ -163,7 +162,7 @@ module StateMachines
163
162
  # for the <tt>:second_gear</tt> state. To avoid this, you can define your
164
163
  # custom validation like so:
165
164
  #
166
- # class Vehicle < ActiveRecord::Base
165
+ # class Vehicle < ApplicationRecord
167
166
  # state_machine do
168
167
  # ...
169
168
  # state :first_gear, :second_gear do
@@ -199,28 +198,28 @@ module StateMachines
199
198
  #
200
199
  # == Scopes
201
200
  #
202
- # To assist in filtering models with specific states, a series of named
203
- # scopes are defined on the model for finding records with or without a
201
+ # To assist in filtering models with specific states, a series of scopes
202
+ # are defined on the model for finding records with or without a
204
203
  # particular set of states.
205
204
  #
206
- # These named scopes are essentially the functional equivalent of the
205
+ # These scopes are essentially the functional equivalent of the
207
206
  # following definitions:
208
207
  #
209
- # class Vehicle < ActiveRecord::Base
210
- # named_scope :with_states, lambda {|*states| {:conditions => {:state => states}}}
208
+ # class Vehicle < ApplicationRecord
211
209
  # # with_states also aliased to with_state
210
+ # scope :with_states, ->(states) { where(state: states) }
212
211
  #
213
- # named_scope :without_states, lambda {|*states| {:conditions => ['state NOT IN (?)', states]}}
214
212
  # # without_states also aliased to without_state
213
+ # scope :without_states, ->(states) { where.not(state: states) }
215
214
  # end
216
215
  #
217
216
  # *Note*, however, that the states are converted to their stored values
218
217
  # before being passed into the query.
219
218
  #
220
- # Because of the way named scopes work in ActiveRecord, they can be
219
+ # Because of the way scopes work in ActiveRecord, they can be
221
220
  # chained like so:
222
221
  #
223
- # Vehicle.with_state(:parked).all(:order => 'id DESC')
222
+ # Vehicle.with_state(:parked).order(id: :desc)
224
223
  #
225
224
  # Note that states can also be referenced by the string version of their
226
225
  # name:
@@ -235,7 +234,7 @@ module StateMachines
235
234
  #
236
235
  # For example,
237
236
  #
238
- # class Vehicle < ActiveRecord::Base
237
+ # class Vehicle < ApplicationRecord
239
238
  # state_machine :initial => :parked do
240
239
  # before_transition any => :idling do |vehicle|
241
240
  # vehicle.put_on_seatbelt
@@ -266,11 +265,11 @@ module StateMachines
266
265
  # ActiveRecord, a save failure will cause any records that get created in
267
266
  # your callback to roll back. You can work around this issue like so:
268
267
  #
269
- # class TransitionLog < ActiveRecord::Base
270
- # establish_connection Rails.env.to_sym
268
+ # class TransitionLog < ApplicationRecord
269
+ # connects_to database: { writing: :primary, reading: :primary }
271
270
  # end
272
271
  #
273
- # class Vehicle < ActiveRecord::Base
272
+ # class Vehicle < ApplicationRecord
274
273
  # state_machine do
275
274
  # after_failure do |vehicle, transition|
276
275
  # TransitionLog.create(:vehicle => vehicle, :transition => transition)
@@ -280,7 +279,7 @@ module StateMachines
280
279
  # end
281
280
  # end
282
281
  #
283
- # The +TransitionLog+ model establishes a second connection to the database
282
+ # The +TransitionLog+ model establishes a separate connection to the database
284
283
  # that allows new records to be saved without being affected by rollbacks
285
284
  # in the +Vehicle+ model's transaction.
286
285
  #
@@ -305,65 +304,9 @@ module StateMachines
305
304
  # * (-) end transaction (if enabled)
306
305
  # * (9) after_commit
307
306
  #
308
- # == Observers
309
- #
310
- # In addition to support for ActiveRecord-like hooks, there is additional
311
- # support for ActiveRecord observers. Because of the way ActiveRecord
312
- # observers are designed, there is less flexibility around the specific
313
- # transitions that can be hooked in. However, a large number of hooks
314
- # *are* supported. For example, if a transition for a record's +state+
315
- # attribute changes the state from +parked+ to +idling+ via the +ignite+
316
- # event, the following observer methods are supported:
317
- # * before/after/after_failure_to-_ignite_from_parked_to_idling
318
- # * before/after/after_failure_to-_ignite_from_parked
319
- # * before/after/after_failure_to-_ignite_to_idling
320
- # * before/after/after_failure_to-_ignite
321
- # * before/after/after_failure_to-_transition_state_from_parked_to_idling
322
- # * before/after/after_failure_to-_transition_state_from_parked
323
- # * before/after/after_failure_to-_transition_state_to_idling
324
- # * before/after/after_failure_to-_transition_state
325
- # * before/after/after_failure_to-_transition
326
- #
327
- # The following class shows an example of some of these hooks:
328
- #
329
- # class VehicleObserver < ActiveRecord::Observer
330
- # def before_save(vehicle)
331
- # # log message
332
- # end
333
- #
334
- # # Callback for :ignite event *before* the transition is performed
335
- # def before_ignite(vehicle, transition)
336
- # # log message
337
- # end
338
- #
339
- # # Callback for :ignite event *after* the transition has been performed
340
- # def after_ignite(vehicle, transition)
341
- # # put on seatbelt
342
- # end
343
- #
344
- # # Generic transition callback *before* the transition is performed
345
- # def after_transition(vehicle, transition)
346
- # Audit.log(vehicle, transition)
347
- # end
348
- # end
349
- #
350
- # More flexible transition callbacks can be defined directly within the
351
- # model as described in StateMachines::Machine#before_transition
352
- # and StateMachines::Machine#after_transition.
353
- #
354
- # To define a single observer for multiple state machines:
355
- #
356
- # class StateMachineObserver < ActiveRecord::Observer
357
- # observe Vehicle, Switch, Project
358
- #
359
- # def after_transition(record, transition)
360
- # Audit.log(record, transition)
361
- # end
362
- # end
363
- #
364
307
  # == Internationalization
365
308
  #
366
- # In Rails 2.2+, any error message that is generated from performing invalid
309
+ # Any error message that is generated from performing invalid
367
310
  # transitions can be localized. The following default translations are used:
368
311
  #
369
312
  # en:
@@ -376,9 +319,6 @@ module StateMachines
376
319
  # # %{value} = attribute value, %{event} = Human event name, %{state} = Human current state name
377
320
  # invalid_transition: "cannot transition via %{event}"
378
321
  #
379
- # Notice that the interpolation syntax is %{key} in Rails 3+. In Rails 2.x,
380
- # the appropriate syntax is {{key}}.
381
- #
382
322
  # You can override these for a specific model like so:
383
323
  #
384
324
  # en:
@@ -435,72 +375,23 @@ module StateMachines
435
375
  end
436
376
 
437
377
  # Gets the db default for the machine's attribute
438
- if ::ActiveRecord.gem_version >= Gem::Version.new('4.2.0')
439
- def owner_class_attribute_default
440
- if owner_class.connected? && owner_class.table_exists?
441
- owner_class.column_defaults[attribute.to_s]
442
- end
443
- end
444
- else
445
- def owner_class_attribute_default
446
- if owner_class.connected? && owner_class.table_exists?
447
- if column = owner_class.columns_hash[attribute.to_s]
448
- column.default
449
- end
450
- end
378
+ def owner_class_attribute_default
379
+ if owner_class.connected? && owner_class.table_exists?
380
+ owner_class.column_defaults[attribute.to_s]
451
381
  end
452
382
  end
453
383
 
454
384
  def define_state_initializer
455
- if ::ActiveRecord.gem_version >= Gem::Version.new('5.0.0.alpha')
456
- define_helper :instance, <<-end_eval, __FILE__, __LINE__ + 1
457
- def initialize(attributes = nil, *)
458
- super(attributes) do |*args|
459
- scoped_attributes = (attributes || {}).merge(self.class.scope_attributes)
460
-
461
- self.class.state_machines.initialize_states(self, {}, scoped_attributes)
462
- yield(*args) if block_given?
463
- end
464
- end
465
- end_eval
466
- elsif ::ActiveRecord.gem_version >= Gem::Version.new('4.2')
467
- define_helper :instance, <<-end_eval, __FILE__, __LINE__ + 1
468
- def initialize(attributes = nil, options = {})
385
+ define_helper :instance, <<-end_eval, __FILE__, __LINE__ + 1
386
+ def initialize(attributes = nil, *)
387
+ super(attributes) do |*args|
469
388
  scoped_attributes = (attributes || {}).merge(self.class.scope_attributes)
470
389
 
471
- super(attributes, options) do |*args|
472
- self.class.state_machines.initialize_states(self, {}, scoped_attributes)
473
- yield(*args) if block_given?
474
- end
390
+ self.class.state_machines.initialize_states(self, {}, scoped_attributes)
391
+ yield(*args) if block_given?
475
392
  end
476
- end_eval
477
- else
478
- # Initializes static states
479
- #
480
- # This is the only available hook where the default set of attributes
481
- # can be overridden for a new object *prior* to the processing of the
482
- # attributes passed into #initialize
483
- define_helper :class, <<-end_eval, __FILE__, __LINE__ + 1
484
- def column_defaults(*) #:nodoc:
485
- result = super
486
- # No need to pass in an object, since the overrides will be forced
487
- self.state_machines.initialize_states(nil, :static => :force, :dynamic => false, :to => result)
488
- result
489
- end
490
- end_eval
491
-
492
- # Initializes dynamic states
493
- define_helper :instance, <<-end_eval, __FILE__, __LINE__ + 1
494
- def initialize(attributes = nil, options = {})
495
- scoped_attributes = (attributes || {}).merge(self.class.scope_attributes)
496
-
497
- super(attributes, options) do |*args|
498
- self.class.state_machines.initialize_states(self, {}, scoped_attributes)
499
- yield(*args) if block_given?
500
- end
501
- end
502
- end_eval
503
- end
393
+ end
394
+ end_eval
504
395
  end
505
396
 
506
397
  # Uses around callbacks to run state events if using the :save hook
@@ -565,7 +456,7 @@ module StateMachines
565
456
 
566
457
  private
567
458
 
568
- # Defines a new named scope with the given name
459
+ # Defines a new scope with the given name
569
460
  def create_scope(name, scope)
570
461
  lambda { |model, values| model.where(scope.call(values)) }
571
462
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support'
2
4
  require 'state_machines/integrations/active_record'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ActiveRecord::Base.connection.create_table(:posts, :force => true) do |t|
2
4
  t.string :title
3
5
  t.string :content
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class IntegrationTest < BaseTestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class MachineByDefaultTest < BaseTestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class MachineErrorsTest < BaseTestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class MachineMultipleTest < BaseTestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class MachineNestedActionTest < BaseTestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class MachineUnmigratedTest < BaseTestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class MachineWithAliasedAttributeTest < BaseTestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class MachineWithCallbacksTest < BaseTestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class MachineWithColumnStateAttributeTest < BaseTestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class MachineWithComplexPluralizationScopesTest < BaseTestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class MachineWithConflictingPredicateTest < BaseTestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
  require 'stringio'
3
5
 
@@ -12,14 +14,14 @@ class MachineWithConflictingStateNameTest < BaseTestCase
12
14
  @machine = StateMachines::Machine.new(@model)
13
15
  @machine.state :state
14
16
 
15
- assert_match(/^Instance method "state\?" is already defined in Foo, use generic helper instead.*\n$/, $stderr.string)
17
+ assert_match(/^Instance method "state\?" is already defined in .+, use generic helper instead.*\n$/, $stderr.string)
16
18
  end
17
19
 
18
20
  def test_should_output_warning_with_same_machine_attribute
19
21
  @machine = StateMachines::Machine.new(@model, :public_state, :attribute => :state)
20
22
  @machine.state :state
21
23
 
22
- assert_match(/^Instance method "state\?" is already defined in Foo, use generic helper instead.*\n$/, $stderr.string)
24
+ assert_match(/^Instance method "state\?" is already defined in .+, use generic helper instead.*\n$/, $stderr.string)
23
25
  end
24
26
 
25
27
  def teardown
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
  require 'stringio'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class MachineWithDefaultScopeTest < BaseTestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
  require 'stringio'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
  require 'stringio'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class MachineWithDirtyAttributeAndCustomAttributesDuringLoopbackTest < BaseTestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class MachineWithDirtyAttributeAndStateEventsTest < BaseTestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class MachineWithDirtyAttributesAndCustomAttributeTest < BaseTestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class MachineWithDirtyAttributesDuringLoopbackTest < BaseTestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class MachineWithDirtyAttributesTest < BaseTestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class MachineWithDynamicInitialStateTest < BaseTestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class MachineWithEventAttributesOnAutosaveTest < BaseTestCase
@@ -42,7 +44,7 @@ class MachineWithEventAttributesOnAutosaveTest < BaseTestCase
42
44
  remove_const('Vehicle')
43
45
  remove_const('Owner')
44
46
  end
45
- ActiveSupport::Dependencies.clear if defined?(ActiveSupport::Dependencies)
47
+ clear_active_support_dependencies
46
48
  super
47
49
  end
48
50
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class MachineWithEventAttributesOnCustomActionTest < BaseTestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class MachineWithEventAttributesOnSaveBangTest < BaseTestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  class MachineWithEventAttributesOnSaveTest < BaseTestCase