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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '07548e72198d3efbe3164700acee48b30c0fae61606b8e56304a078f8f2b7d37'
4
- data.tar.gz: 750c6c7f3fa4f9099d64afffe2ed3faa55c6536e33da9b4dd14283e3a3fc39ab
3
+ metadata.gz: fd332665b3cb66bb2d454e378a7e591e03c06ca4ec8fa36e2f9b69ada1889af8
4
+ data.tar.gz: cdd845b1804643b723f9eb328cbeaa773797fac3f1caf2b4cb5f758d266746a2
5
5
  SHA512:
6
- metadata.gz: 15a2d47316506e5e2345242a94e6aef09110f0944c2f8b2a4bb726027e45f500c7b51661093df8028db21b60f1afbf1bfc7792f37fb315edf7fad4291ef64712
7
- data.tar.gz: 25bf0708566b48822316977e446fc543823ce702219c5584eb439b4f10e5bac51f08636e1fc207fc840fbe73c7d9dbe3b0a1c041923184bd5da6d5693033965b
6
+ metadata.gz: b5bc3b2f8eaf809edc0537f28291f420113ad8d538e79557fb3f7f84e54dc978ff9774be4a9af3a16d2de9d7626c6ed6c960d339a3a0d270941723fa4cfa4fb2
7
+ data.tar.gz: b8d8bb09ef31fb5792e482e06a7f75a6c4ea75b5a335762e950fc1088ecdad15327264ade1b12504ad9a96c8391ba4f13959b5517c442ff171896b10b1de1e60
@@ -24,15 +24,16 @@ jobs:
24
24
  strategy:
25
25
  fail-fast: false
26
26
  matrix:
27
- ruby-version: ["2.7", "3.0", "3.1", "3.2"]
27
+ ruby-version: ["3.0", "3.1", "3.2"]
28
28
  rails-version:
29
- - "6.1.5"
30
- - "7.0.4"
29
+ - "6.1.7.6"
30
+ - "7.0.8"
31
+ - "7.1.1"
31
32
  - "main"
32
- postgres-version: ["9.6", "11", "14"]
33
+ postgres-version: ["12", "13", "14", "15", "16"]
33
34
  exclude:
34
35
  - ruby-version: "3.2"
35
- rails-version: "6.1.5"
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: ["2.7", "3.0", "3.1", "3.2"]
70
+ ruby-version: ["3.0", "3.1", "3.2"]
70
71
  rails-version:
71
- - "6.1.5"
72
- - "7.0.4"
72
+ - "6.1.7.6"
73
+ - "7.0.8"
74
+ - "7.1.1"
73
75
  - "main"
74
- mysql-version: ["5.7", "8.0"]
76
+ mysql-version: ["8.0", "8.2"]
75
77
  exclude:
76
78
  - ruby-version: 3.2
77
- rails-version: "6.1.5"
79
+ rails-version: "6.1.7.6"
78
80
  runs-on: ubuntu-latest
79
81
  services:
80
82
  mysql:
data/.rubocop.yml CHANGED
@@ -15,3 +15,6 @@ Metrics/CyclomaticComplexity:
15
15
 
16
16
  Metrics/PerceivedComplexity:
17
17
  Max: 11
18
+
19
+ Gemspec/DevelopmentDependencies:
20
+ Enabled: false
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.2.0
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" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.2.0")
15
+ gem "test-unit", "~> 3.3"
16
16
  end
@@ -11,7 +11,7 @@ module Statesman
11
11
  end
12
12
 
13
13
  def migration_class_name
14
- klass.gsub(/::/, "").pluralize
14
+ klass.gsub("::", "").pluralize
15
15
  end
16
16
 
17
17
  def next_migration_number
@@ -246,13 +246,8 @@ module Statesman
246
246
  end
247
247
 
248
248
  def serialized?(transition_class)
249
- if ::ActiveRecord.respond_to?(:gem_version) &&
250
- ::ActiveRecord.gem_version >= Gem::Version.new("4.2.0.a")
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)
@@ -53,7 +53,7 @@ module Statesman
53
53
  define_method(:reload) do |*a|
54
54
  instance = super(*a)
55
55
  if instance.respond_to?(:state_machine, true)
56
- instance.state_machine.reset
56
+ instance.send(:state_machine).reset
57
57
  end
58
58
  instance
59
59
  end
@@ -10,7 +10,11 @@ module Statesman
10
10
  extend ActiveSupport::Concern
11
11
 
12
12
  included do
13
- serialize :metadata, JSON
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Statesman
4
- VERSION = "10.2.2"
4
+ VERSION = "11.0.0"
5
5
  end
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: true) do
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: true do
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: true do
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
- if ActiveRecord.respond_to?(:gem_version) &&
42
- ActiveRecord.gem_version >= Gem::Version.new("4.2.0.a")
43
- expect(MyActiveRecordModelTransition).
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
- if ActiveRecord.respond_to?(:gem_version) &&
95
- ActiveRecord.gem_version >= Gem::Version.new("4.2.0.a")
96
- serialized_type = ActiveRecord::Type::Serialized.new(
97
- "", ActiveRecord::Coders::JSON
98
- )
99
- expect(MyActiveRecordModelTransition).
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
- expect(transition_class).to receive(:serialize).with(:metadata, JSON).once
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: true do
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(
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- describe Statesman do
5
+ describe "Exceptions" do
6
6
  describe "InvalidStateError" do
7
7
  subject(:error) { Statesman::InvalidStateError.new }
8
8
 
@@ -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
- serialize :metadata, JSON
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.6.0"
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.5"
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: 10.2.2
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-04-21 00:00:00.000000000 Z
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.6.0
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.6.0
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.5'
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.5'
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.1
297
+ rubygems_version: 3.4.10
298
298
  signing_key:
299
299
  specification_version: 4
300
300
  summary: A statesman-like state machine library