statesman 10.2.2 → 11.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +12 -10
- data/.rubocop.yml +3 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +14 -0
- data/Gemfile +2 -2
- data/lib/generators/statesman/generator_helpers.rb +1 -1
- data/lib/statesman/adapters/active_record.rb +2 -7
- data/lib/statesman/adapters/active_record_queries.rb +1 -1
- data/lib/statesman/adapters/active_record_transition.rb +5 -1
- data/lib/statesman/version.rb +1 -1
- data/spec/spec_helper.rb +1 -3
- data/spec/statesman/adapters/active_record_queries_spec.rb +1 -1
- data/spec/statesman/adapters/active_record_spec.rb +11 -27
- data/spec/statesman/adapters/active_record_transition_spec.rb +5 -1
- data/spec/statesman/adapters/type_safe_active_record_queries_spec.rb +1 -1
- data/spec/statesman/exceptions_spec.rb +1 -1
- data/spec/support/active_record.rb +5 -5
- data/statesman.gemspec +2 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd332665b3cb66bb2d454e378a7e591e03c06ca4ec8fa36e2f9b69ada1889af8
|
4
|
+
data.tar.gz: cdd845b1804643b723f9eb328cbeaa773797fac3f1caf2b4cb5f758d266746a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5bc3b2f8eaf809edc0537f28291f420113ad8d538e79557fb3f7f84e54dc978ff9774be4a9af3a16d2de9d7626c6ed6c960d339a3a0d270941723fa4cfa4fb2
|
7
|
+
data.tar.gz: b8d8bb09ef31fb5792e482e06a7f75a6c4ea75b5a335762e950fc1088ecdad15327264ade1b12504ad9a96c8391ba4f13959b5517c442ff171896b10b1de1e60
|
data/.github/workflows/tests.yml
CHANGED
@@ -24,15 +24,16 @@ jobs:
|
|
24
24
|
strategy:
|
25
25
|
fail-fast: false
|
26
26
|
matrix:
|
27
|
-
ruby-version: ["
|
27
|
+
ruby-version: ["3.0", "3.1", "3.2"]
|
28
28
|
rails-version:
|
29
|
-
- "6.1.
|
30
|
-
- "7.0.
|
29
|
+
- "6.1.7.6"
|
30
|
+
- "7.0.8"
|
31
|
+
- "7.1.1"
|
31
32
|
- "main"
|
32
|
-
postgres-version: ["
|
33
|
+
postgres-version: ["12", "13", "14", "15", "16"]
|
33
34
|
exclude:
|
34
35
|
- ruby-version: "3.2"
|
35
|
-
rails-version: "6.1.
|
36
|
+
rails-version: "6.1.7.6"
|
36
37
|
runs-on: ubuntu-latest
|
37
38
|
services:
|
38
39
|
postgres:
|
@@ -66,15 +67,16 @@ jobs:
|
|
66
67
|
strategy:
|
67
68
|
fail-fast: false
|
68
69
|
matrix:
|
69
|
-
ruby-version: ["
|
70
|
+
ruby-version: ["3.0", "3.1", "3.2"]
|
70
71
|
rails-version:
|
71
|
-
- "6.1.
|
72
|
-
- "7.0.
|
72
|
+
- "6.1.7.6"
|
73
|
+
- "7.0.8"
|
74
|
+
- "7.1.1"
|
73
75
|
- "main"
|
74
|
-
mysql-version: ["
|
76
|
+
mysql-version: ["8.0", "8.2"]
|
75
77
|
exclude:
|
76
78
|
- ruby-version: 3.2
|
77
|
-
rails-version: "6.1.
|
79
|
+
rails-version: "6.1.7.6"
|
78
80
|
runs-on: ubuntu-latest
|
79
81
|
services:
|
80
82
|
mysql:
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.2.
|
1
|
+
3.2.2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## v11.0.0 3rd November 2023
|
2
|
+
|
3
|
+
### Changed
|
4
|
+
- Updated to support ActiveRecord > 7.2
|
5
|
+
- Remove support for:
|
6
|
+
- Ruby; 2.7
|
7
|
+
- Postgres; 9.6, 10, 11
|
8
|
+
- MySQL; 5.7
|
9
|
+
|
10
|
+
## v10.2.3 2nd Aug 2023
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
- Fixed calls to reloading internal cache is the state_machine was made private / protected
|
14
|
+
|
1
15
|
## v10.2.2 21st April 2023
|
2
16
|
|
3
17
|
### Changed
|
data/Gemfile
CHANGED
@@ -9,8 +9,8 @@ if ENV['RAILS_VERSION'] == 'main'
|
|
9
9
|
elsif ENV['RAILS_VERSION']
|
10
10
|
gem "rails", "~> #{ENV['RAILS_VERSION']}"
|
11
11
|
end
|
12
|
+
|
12
13
|
group :development do
|
13
|
-
# test/unit is no longer bundled with Ruby 2.2, but required by Rails
|
14
14
|
gem "pry"
|
15
|
-
gem "test-unit", "~> 3.3"
|
15
|
+
gem "test-unit", "~> 3.3"
|
16
16
|
end
|
@@ -246,13 +246,8 @@ module Statesman
|
|
246
246
|
end
|
247
247
|
|
248
248
|
def serialized?(transition_class)
|
249
|
-
|
250
|
-
|
251
|
-
transition_class.type_for_attribute("metadata").
|
252
|
-
is_a?(::ActiveRecord::Type::Serialized)
|
253
|
-
else
|
254
|
-
transition_class.serialized_attributes.include?("metadata")
|
255
|
-
end
|
249
|
+
transition_class.type_for_attribute("metadata").
|
250
|
+
is_a?(::ActiveRecord::Type::Serialized)
|
256
251
|
end
|
257
252
|
|
258
253
|
def transition_conflict_error?(err)
|
@@ -10,7 +10,11 @@ module Statesman
|
|
10
10
|
extend ActiveSupport::Concern
|
11
11
|
|
12
12
|
included do
|
13
|
-
|
13
|
+
if ::ActiveRecord.gem_version >= Gem::Version.new("7.1")
|
14
|
+
serialize :metadata, coder: JSON
|
15
|
+
else
|
16
|
+
serialize :metadata, JSON
|
17
|
+
end
|
14
18
|
|
15
19
|
class_attribute :updated_timestamp_column
|
16
20
|
self.updated_timestamp_column = DEFAULT_UPDATED_TIMESTAMP_COLUMN
|
data/lib/statesman/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -40,7 +40,7 @@ RSpec.configure do |config|
|
|
40
40
|
ActiveRecord::Migration.verbose = false
|
41
41
|
end
|
42
42
|
|
43
|
-
config.before(:each, active_record
|
43
|
+
config.before(:each, :active_record) do
|
44
44
|
tables = %w[
|
45
45
|
my_active_record_models
|
46
46
|
my_active_record_model_transitions
|
@@ -82,7 +82,5 @@ RSpec.configure do |config|
|
|
82
82
|
CreateStiActiveRecordModelTransitionMigration.migrate(:up)
|
83
83
|
StiActiveRecordModelTransition.reset_column_information
|
84
84
|
end
|
85
|
-
|
86
|
-
MyNamespace::MyActiveRecordModelTransition.serialize(:metadata, JSON)
|
87
85
|
end
|
88
86
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe Statesman::Adapters::ActiveRecordQueries, active_record
|
5
|
+
describe Statesman::Adapters::ActiveRecordQueries, :active_record do
|
6
6
|
def configure_old(klass, transition_class)
|
7
7
|
klass.define_singleton_method(:transition_class) { transition_class }
|
8
8
|
klass.define_singleton_method(:initial_state) { :initial }
|
@@ -5,12 +5,12 @@ require "timecop"
|
|
5
5
|
require "statesman/adapters/shared_examples"
|
6
6
|
require "statesman/exceptions"
|
7
7
|
|
8
|
-
describe Statesman::Adapters::ActiveRecord, active_record
|
8
|
+
describe Statesman::Adapters::ActiveRecord, :active_record do
|
9
9
|
before do
|
10
10
|
prepare_model_table
|
11
11
|
prepare_transitions_table
|
12
12
|
|
13
|
-
MyActiveRecordModelTransition.serialize(:metadata, JSON)
|
13
|
+
# MyActiveRecordModelTransition.serialize(:metadata, JSON)
|
14
14
|
|
15
15
|
prepare_sti_model_table
|
16
16
|
prepare_sti_transitions_table
|
@@ -38,15 +38,9 @@ describe Statesman::Adapters::ActiveRecord, active_record: true do
|
|
38
38
|
allow(metadata_column).to receive_messages(sql_type: "")
|
39
39
|
allow(MyActiveRecordModelTransition).to receive_messages(columns_hash:
|
40
40
|
{ "metadata" => metadata_column })
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
to receive(:type_for_attribute).with("metadata").
|
45
|
-
and_return(ActiveRecord::Type::Value.new)
|
46
|
-
else
|
47
|
-
expect(MyActiveRecordModelTransition).
|
48
|
-
to receive_messages(serialized_attributes: {})
|
49
|
-
end
|
41
|
+
expect(MyActiveRecordModelTransition).
|
42
|
+
to receive(:type_for_attribute).with("metadata").
|
43
|
+
and_return(ActiveRecord::Type::Value.new)
|
50
44
|
end
|
51
45
|
|
52
46
|
it "raises an exception" do
|
@@ -91,18 +85,12 @@ describe Statesman::Adapters::ActiveRecord, active_record: true do
|
|
91
85
|
allow(metadata_column).to receive_messages(sql_type: "jsonb")
|
92
86
|
allow(MyActiveRecordModelTransition).to receive_messages(columns_hash:
|
93
87
|
{ "metadata" => metadata_column })
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
)
|
99
|
-
|
100
|
-
to receive(:type_for_attribute).with("metadata").
|
101
|
-
and_return(serialized_type)
|
102
|
-
else
|
103
|
-
expect(MyActiveRecordModelTransition).
|
104
|
-
to receive_messages(serialized_attributes: { "metadata" => "" })
|
105
|
-
end
|
88
|
+
serialized_type = ActiveRecord::Type::Serialized.new(
|
89
|
+
"", ActiveRecord::Coders::JSON
|
90
|
+
)
|
91
|
+
expect(MyActiveRecordModelTransition).
|
92
|
+
to receive(:type_for_attribute).with("metadata").
|
93
|
+
and_return(serialized_type)
|
106
94
|
end
|
107
95
|
|
108
96
|
it "raises an exception" do
|
@@ -467,10 +455,6 @@ describe Statesman::Adapters::ActiveRecord, active_record: true do
|
|
467
455
|
CreateNamespacedARModelTransitionMigration.migrate(:up)
|
468
456
|
end
|
469
457
|
|
470
|
-
before do
|
471
|
-
MyNamespace::MyActiveRecordModelTransition.serialize(:metadata, JSON)
|
472
|
-
end
|
473
|
-
|
474
458
|
let(:observer) { double(Statesman::Machine, execute: nil) }
|
475
459
|
let(:model) do
|
476
460
|
MyNamespace::MyActiveRecordModel.create(current_state: :pending)
|
@@ -8,7 +8,11 @@ describe Statesman::Adapters::ActiveRecordTransition do
|
|
8
8
|
|
9
9
|
describe "including behaviour" do
|
10
10
|
it "calls Class.serialize" do
|
11
|
-
|
11
|
+
if Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new("7.1")
|
12
|
+
expect(transition_class).to receive(:serialize).with(:metadata, coder: JSON).once
|
13
|
+
else
|
14
|
+
expect(transition_class).to receive(:serialize).with(:metadata, JSON).once
|
15
|
+
end
|
12
16
|
transition_class.send(:include, described_class)
|
13
17
|
end
|
14
18
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe Statesman::Adapters::TypeSafeActiveRecordQueries, active_record
|
5
|
+
describe Statesman::Adapters::TypeSafeActiveRecordQueries, :active_record do
|
6
6
|
def configure(klass, transition_class)
|
7
7
|
klass.send(:extend, described_class)
|
8
8
|
klass.configure_state_machine(
|
@@ -24,7 +24,6 @@ class MyActiveRecordModelTransition < ActiveRecord::Base
|
|
24
24
|
include Statesman::Adapters::ActiveRecordTransition
|
25
25
|
|
26
26
|
belongs_to :my_active_record_model
|
27
|
-
serialize :metadata, JSON
|
28
27
|
end
|
29
28
|
|
30
29
|
class MyActiveRecordModel < ActiveRecord::Base
|
@@ -51,7 +50,11 @@ class MyActiveRecordModelTransitionWithoutInclude < ActiveRecord::Base
|
|
51
50
|
self.table_name = "my_active_record_model_transitions"
|
52
51
|
|
53
52
|
belongs_to :my_active_record_model
|
54
|
-
|
53
|
+
if ::ActiveRecord.gem_version >= Gem::Version.new("7.1")
|
54
|
+
serialize :metadata, coder: JSON
|
55
|
+
else
|
56
|
+
serialize :metadata, JSON
|
57
|
+
end
|
55
58
|
end
|
56
59
|
|
57
60
|
class CreateMyActiveRecordModelMigration < MIGRATION_CLASS
|
@@ -129,7 +132,6 @@ class OtherActiveRecordModelTransition < ActiveRecord::Base
|
|
129
132
|
include Statesman::Adapters::ActiveRecordTransition
|
130
133
|
|
131
134
|
belongs_to :other_active_record_model
|
132
|
-
serialize :metadata, JSON
|
133
135
|
end
|
134
136
|
|
135
137
|
class CreateOtherActiveRecordModelMigration < MIGRATION_CLASS
|
@@ -221,7 +223,6 @@ module MyNamespace
|
|
221
223
|
|
222
224
|
belongs_to :my_active_record_model,
|
223
225
|
class_name: "MyNamespace::MyActiveRecordModel"
|
224
|
-
serialize :metadata, JSON
|
225
226
|
|
226
227
|
def self.table_name_prefix
|
227
228
|
"my_namespace_"
|
@@ -310,7 +311,6 @@ class StiActiveRecordModelTransition < ActiveRecord::Base
|
|
310
311
|
include Statesman::Adapters::ActiveRecordTransition
|
311
312
|
|
312
313
|
belongs_to :sti_active_record_model
|
313
|
-
serialize :metadata, JSON
|
314
314
|
end
|
315
315
|
|
316
316
|
class StiAActiveRecordModelTransition < StiActiveRecordModelTransition
|
data/statesman.gemspec
CHANGED
@@ -24,9 +24,9 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.add_development_dependency "ammeter", "~> 1.1"
|
26
26
|
spec.add_development_dependency "bundler", "~> 2"
|
27
|
-
spec.add_development_dependency "gc_ruboconfig", "~> 3.
|
27
|
+
spec.add_development_dependency "gc_ruboconfig", "~> 4.3.0"
|
28
28
|
spec.add_development_dependency "mysql2", ">= 0.4", "< 0.6"
|
29
|
-
spec.add_development_dependency "pg", ">= 0.18", "<= 1.
|
29
|
+
spec.add_development_dependency "pg", ">= 0.18", "<= 1.6"
|
30
30
|
spec.add_development_dependency "rails", ">= 5.2"
|
31
31
|
spec.add_development_dependency "rake", "~> 13.0.0"
|
32
32
|
spec.add_development_dependency "rspec", "~> 3.1"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statesman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 11.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GoCardless
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ammeter
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.
|
47
|
+
version: 4.3.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.
|
54
|
+
version: 4.3.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: mysql2
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
version: '0.18'
|
82
82
|
- - "<="
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version: '1.
|
84
|
+
version: '1.6'
|
85
85
|
type: :development
|
86
86
|
prerelease: false
|
87
87
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -91,7 +91,7 @@ dependencies:
|
|
91
91
|
version: '0.18'
|
92
92
|
- - "<="
|
93
93
|
- !ruby/object:Gem::Version
|
94
|
-
version: '1.
|
94
|
+
version: '1.6'
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
96
|
name: rails
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
@@ -294,7 +294,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
294
294
|
- !ruby/object:Gem::Version
|
295
295
|
version: '0'
|
296
296
|
requirements: []
|
297
|
-
rubygems_version: 3.4.
|
297
|
+
rubygems_version: 3.4.10
|
298
298
|
signing_key:
|
299
299
|
specification_version: 4
|
300
300
|
summary: A statesman-like state machine library
|