statesman 7.4.0 → 10.2.3

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: f0dbcc9fe3c29e715be585f2ddae96bdea9b80ca104daf00ee3378feab681b8e
4
- data.tar.gz: c5824ece991650b8e6e979a9899dbdabc38b18209a79260f2aa9e9f4fda67da2
3
+ metadata.gz: 0cc749949e382ced6f27722a0eb033efc0383ba11a06265a84e1da3b593eb02d
4
+ data.tar.gz: f2dd851b5c9ccb0aacbde8076c10fcf23bfe8a00926e58acfb9dd714c5d61b99
5
5
  SHA512:
6
- metadata.gz: 98fe2966e48e912b33f1c6d842aa6090782dd32be726532d8178377ffb0f1a551ee3d83eee291de0723c756eb0b1bda65dae73d695a47f8b6bd38106b127615f
7
- data.tar.gz: 6be77a7114e2c3d59e76cfa71de583213ead8a171c5039941698c1e4b0b28b68500acba91d498fb488d33d0e31b3274fa5e373ce81a55f9f70e8e229132de1cf
6
+ metadata.gz: 4ac72394722dc0d193874967e79bb30df1a1c7ba63e4eccd20294f2298b2e78637b3c7ffff7fe4ef4f4ad5d3ca522efe89444400fa09231684622848754a7683
7
+ data.tar.gz: e995d62de4ec4471ec1a66fea6e290bfbc5f0a3420c3bd915117a0e92f08ca20994b59e84ed5f73a93d091156ea47ef35548ea61f50ad52a1942a69438d4f446
@@ -0,0 +1,7 @@
1
+ version: 2
2
+
3
+ updates:
4
+ - package-ecosystem: bundler
5
+ directory: "/"
6
+ schedule:
7
+ interval: "daily"
@@ -0,0 +1,106 @@
1
+ name: tests
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - "master"
7
+ pull_request:
8
+
9
+ concurrency:
10
+ group: ${{ github.workflow }}-${{ github.ref }}
11
+ cancel-in-progress: true
12
+
13
+ jobs:
14
+ rubocop:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v3
18
+ - uses: ruby/setup-ruby@v1
19
+ with:
20
+ bundler-cache: true
21
+ - run: bundle exec rubocop --extra-details --display-style-guide --parallel --force-exclusion
22
+
23
+ postgres:
24
+ strategy:
25
+ fail-fast: false
26
+ matrix:
27
+ ruby-version: ["2.7", "3.0", "3.1", "3.2"]
28
+ rails-version:
29
+ - "6.1.5"
30
+ - "7.0.4"
31
+ - "main"
32
+ postgres-version: ["9.6", "11", "14"]
33
+ exclude:
34
+ - ruby-version: "3.2"
35
+ rails-version: "6.1.5"
36
+ runs-on: ubuntu-latest
37
+ services:
38
+ postgres:
39
+ image: postgres:${{ matrix.postgres-version }}
40
+ env:
41
+ POSTGRES_USER: postgres
42
+ POSTGRES_DB: statesman_test
43
+ POSTGRES_PASSWORD: statesman
44
+ ports:
45
+ - 5432:5432
46
+ options: >-
47
+ --health-cmd pg_isready
48
+ --health-interval 10s
49
+ --health-timeout 5s
50
+ --health-retries 10
51
+ env:
52
+ DATABASE_URL: postgres://postgres:statesman@localhost/statesman_test
53
+ DATABASE_DEPENDENCY_PORT: "5432"
54
+ steps:
55
+ - uses: actions/checkout@v3
56
+ - name: Set up Ruby
57
+ uses: ruby/setup-ruby@v1
58
+ with:
59
+ bundler-cache: true
60
+ ruby-version: "${{ matrix.ruby-version }}"
61
+ - name: Run specs
62
+ run: |
63
+ bundle exec rspec --profile --format progress --format RSpec::Github::Formatter
64
+
65
+ mysql:
66
+ strategy:
67
+ fail-fast: false
68
+ matrix:
69
+ ruby-version: ["2.7", "3.0", "3.1", "3.2"]
70
+ rails-version:
71
+ - "6.1.5"
72
+ - "7.0.4"
73
+ - "main"
74
+ mysql-version: ["5.7", "8.0"]
75
+ exclude:
76
+ - ruby-version: 3.2
77
+ rails-version: "6.1.5"
78
+ runs-on: ubuntu-latest
79
+ services:
80
+ mysql:
81
+ image: mysql:${{ matrix.mysql-version }}
82
+ env:
83
+ MYSQL_ROOT_PASSWORD: password
84
+ MYSQL_USER: foobar
85
+ MYSQL_PASSWORD: password
86
+ MYSQL_DATABASE: statesman_test
87
+ ports:
88
+ - "3306:3306"
89
+ options: >-
90
+ --health-cmd "mysqladmin ping"
91
+ --health-interval 10s
92
+ --health-timeout 5s
93
+ --health-retries 5
94
+ env:
95
+ DATABASE_URL: mysql2://foobar:password@127.0.0.1/statesman_test
96
+ DATABASE_DEPENDENCY_PORT: "3306"
97
+ steps:
98
+ - uses: actions/checkout@v3
99
+ - name: Set up Ruby
100
+ uses: ruby/setup-ruby@v1
101
+ with:
102
+ bundler-cache: true
103
+ ruby-version: "${{ matrix.ruby-version }}"
104
+ - name: Run specs
105
+ run: |
106
+ bundle exec rspec --profile --format progress --format RSpec::Github::Formatter
data/.gitignore CHANGED
@@ -1,18 +1,71 @@
1
1
  *.gem
2
2
  *.rbc
3
- .bundle
4
- .config
5
- .rspec
6
- .yardoc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ # Ignore Byebug command history file.
17
+ .byebug_history
18
+
19
+ ## Specific to RubyMotion:
20
+ .dat*
21
+ .repl_history
22
+ build/
23
+ *.bridgesupport
24
+ build-iPhoneOS/
25
+ build-iPhoneSimulator/
26
+
27
+ ## Specific to RubyMotion (use of CocoaPods):
28
+ #
29
+ # We recommend against adding the Pods directory to your .gitignore. However
30
+ # you should judge for yourself, the pros and cons are mentioned at:
31
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32
+ #
33
+ # vendor/Pods/
34
+
35
+ ## Documentation cache and generated files:
36
+ /.yardoc/
37
+ /_yardoc/
38
+ /doc/
39
+ /rdoc/
40
+
41
+ ## Environment normalization:
42
+ /.bundle/
43
+ /vendor/bundle
44
+ /lib/bundler/man/
45
+
46
+ # for a library or gem, you might want to ignore these files since the code is
47
+ # intended to run in multiple environments; otherwise, check them in:
7
48
  Gemfile.lock
8
- InstalledFiles
9
- _yardoc
10
- coverage
11
- doc/
12
- lib/bundler/man
13
- pkg
14
- rdoc
15
- spec/reports
16
- test/tmp
17
- test/version_tmp
18
- tmp
49
+ # .ruby-version
50
+ # .ruby-gemset
51
+
52
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
+ .rvmrc
54
+
55
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
+ # .rubocop-https?--*
57
+
58
+ # Project-specific ignores
59
+ .rspec
60
+
61
+ # VSCode
62
+ .vscode
63
+
64
+ # Local History for Visual Studio Code
65
+ .history/
66
+
67
+ # Built Visual Studio Code Extensions
68
+ *.vsix
69
+
70
+ # JetBrains
71
+ .idea
data/.rubocop.yml CHANGED
@@ -4,4 +4,17 @@ inherit_gem:
4
4
  gc_ruboconfig: rubocop.yml
5
5
 
6
6
  AllCops:
7
- TargetRubyVersion: 2.4
7
+ TargetRubyVersion: 2.7
8
+ NewCops: enable
9
+
10
+ Metrics/AbcSize:
11
+ Max: 60
12
+
13
+ Metrics/CyclomaticComplexity:
14
+ Max: 10
15
+
16
+ Metrics/PerceivedComplexity:
17
+ Max: 11
18
+
19
+ Gemspec/DevelopmentDependencies:
20
+ Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -1,38 +1,42 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2019-08-17 15:19:58 +0100 using RuboCop version 0.61.1.
3
+ # on 2021-08-09 15:32:40 UTC using RuboCop version 1.18.4.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
+ # Offense count: 1
10
+ # Configuration parameters: Include.
11
+ # Include: **/*.gemspec
9
12
  Gemspec/RequiredRubyVersion:
10
- Enabled: false # We want to allow Ruby 2.2 even though we don't test on it
13
+ Exclude:
14
+ - 'statesman.gemspec'
15
+
16
+ # Offense count: 1
17
+ Lint/MissingSuper:
18
+ Exclude:
19
+ - 'lib/statesman/adapters/active_record_queries.rb'
11
20
 
12
21
  # Offense count: 5
22
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
13
23
  Metrics/AbcSize:
14
- Max: 18
24
+ Max: 20
25
+
26
+ # Offense count: 1
27
+ # Configuration parameters: IgnoredMethods.
28
+ Metrics/CyclomaticComplexity:
29
+ Max: 8
15
30
 
16
- # Offense count: 4
17
- # Configuration parameters: CountComments, ExcludedMethods.
31
+ # Offense count: 3
32
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
18
33
  Metrics/MethodLength:
19
34
  Max: 14
20
35
 
21
- # Offense count: 2
22
- # Cop supports --auto-correct.
23
- # Configuration parameters: SkipBlocks, EnforcedStyle.
24
- # SupportedStyles: described_class, explicit
25
- RSpec/DescribedClass:
26
- Exclude:
27
- - 'spec/statesman/adapters/active_record_queries_spec.rb'
28
-
29
- # Offense count: 7
30
- # Configuration parameters: Max.
36
+ # Offense count: 11
37
+ # Configuration parameters: CountAsOne.
31
38
  RSpec/ExampleLength:
32
- Exclude:
33
- - 'spec/statesman/adapters/active_record_spec.rb'
34
- - 'spec/statesman/adapters/shared_examples.rb'
35
- - 'spec/statesman/machine_spec.rb'
39
+ Max: 14
36
40
 
37
41
  # Offense count: 7
38
42
  RSpec/ExpectInHook:
@@ -40,11 +44,12 @@ RSpec/ExpectInHook:
40
44
  - 'spec/statesman/adapters/active_record_spec.rb'
41
45
  - 'spec/statesman/machine_spec.rb'
42
46
 
43
- # Offense count: 3
44
- RSpec/ImplicitBlockExpectation:
47
+ # Offense count: 1
48
+ # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
49
+ # Include: **/*_spec*rb*, **/spec/**/*
50
+ RSpec/FilePath:
45
51
  Exclude:
46
- - 'spec/statesman/adapters/active_record_spec.rb'
47
- - 'spec/statesman/adapters/shared_examples.rb'
52
+ - 'spec/statesman/exceptions_spec.rb'
48
53
 
49
54
  # Offense count: 1
50
55
  # Configuration parameters: AssignmentOnly.
@@ -75,23 +80,27 @@ RSpec/MessageSpies:
75
80
  Exclude:
76
81
  - 'spec/statesman/callback_spec.rb'
77
82
 
78
- # Offense count: 9
79
- # Configuration parameters: AggregateFailuresByDefault.
83
+ # Offense count: 14
80
84
  RSpec/MultipleExpectations:
81
85
  Max: 3
82
86
 
83
- # Offense count: 50
87
+ # Offense count: 49
84
88
  RSpec/NestedGroups:
85
89
  Max: 6
86
90
 
87
- # Offense count: 16
91
+ # Offense count: 2
92
+ RSpec/RepeatedExampleGroupBody:
93
+ Exclude:
94
+ - 'spec/statesman/exceptions_spec.rb'
95
+
96
+ # Offense count: 12
88
97
  RSpec/ScatteredSetup:
89
98
  Exclude:
90
99
  - 'spec/statesman/adapters/active_record_spec.rb'
91
100
  - 'spec/statesman/adapters/shared_examples.rb'
92
101
  - 'spec/statesman/machine_spec.rb'
93
102
 
94
- # Offense count: 8
103
+ # Offense count: 7
95
104
  # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
96
105
  RSpec/VerifiedDoubles:
97
106
  Exclude:
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,84 @@
1
+ ## v10.2.3 2nd Aug 2023
2
+
3
+ ### Changed
4
+ - Fixed calls to reloading internal cache is the state_machine was made private / protected
5
+
6
+ ## v10.2.2 21st April 2023
7
+
8
+ ### Changed
9
+ - Calling `active_record.reload` resets the adapater's internal cache
10
+
11
+ ## v10.2.1 3rd April 2023
12
+
13
+ ### Changed
14
+ - Fixed an edge case where `adapter.reset` were failing if the cache is empty
15
+
16
+ ## v10.2.0 3rd April 2023
17
+
18
+ ### Changed
19
+ - Fixed caching of `last_transition` [#505](https://github.com/gocardless/statesman/pull/505)
20
+
21
+ ## v10.1.0 10th March 2023
22
+
23
+ ### CHanged
24
+ - Add the source location of the guard callback to `Statesman::GuardFailedError`
25
+
26
+ ## v10.0.0 17th May 2022
27
+
28
+ ### Changed
29
+ - Added support for Ruby 3.1 [#462](https://github.com/gocardless/statesman/pull/462)
30
+ - Removed support for Ruby 2.5 and 2.6 [#462](https://github.com/gocardless/statesman/pull/462)
31
+ - Added `remove_state` and `remove_transitions` methods to `Statesman::Machine` [#464](https://github.com/gocardless/statesman/pull/464)
32
+
33
+ ## v9.0.1 4th February 2021
34
+
35
+ ### Changed
36
+ - Deprecate `ActiveRecord::Base.default_timezone` in favour of `ActiveRecord.default_timezone` [#446](https://github.com/gocardless/statesman/pull/446)
37
+
38
+ ## v9.0.0 9th August 2021
39
+
40
+ ### Added
41
+ - Added Ruby 3.0 support
42
+
43
+ ### Breaking changes
44
+
45
+ - Removed Ruby 2.4
46
+
47
+ ## v8.0.3 8th June 2021
48
+
49
+ ### Added
50
+ - Implement `Machine#last_transition_to`, to find the last transition to a given state
51
+ [#438](https://github.com/gocardless/statesman/pull/438)
52
+
53
+ ## v8.0.2 30th March 2021
54
+
55
+ ### Changed
56
+
57
+ - Fixed a bug where the `history` of a model was left in an incorrect state after a transition
58
+ conflict [#433](https://github.com/gocardless/statesman/pull/433)
59
+
60
+ ## v8.0.1 20th January 2021
61
+
62
+ ### Changed
63
+
64
+ - Fixed `no implicit conversion of nil into String` error when quoting null values
65
+ [#427](https://github.com/gocardless/statesman/pull/427)
66
+
67
+ ## v8.0.0 6th January 2021
68
+
69
+ ### Added
70
+
71
+ - Use AR Arel table to type cast booleans in order to avoid deprecation warning [#421](https://github.com/gocardless/statesman/pull/421)
72
+ - Support relationships that doesn't use `id` as a Primary Key
73
+ [#422](https://github.com/gocardless/statesman/pull/422)
74
+
75
+ ## v7.4.1 11th November 2020
76
+
77
+ ### Added
78
+
79
+ - Add #reset method to state machine and adapter interfaces
80
+ [#417](https://github.com/gocardless/statesman/pull/417)
81
+
1
82
  ## v7.4.0 26th August 2020
2
83
 
3
84
  ### Added
@@ -9,16 +90,16 @@
9
90
 
10
91
  ### Changed
11
92
 
12
- - Use correct Arel for null [#409](https://github.com/gocardless/statesman/pull/#409)
93
+ - Use correct Arel for null [#409](https://github.com/gocardless/statesman/pull/409)
13
94
 
14
95
  ## v7.2.0, 19th May 2020
15
96
 
16
97
  ### Changed
17
98
 
18
- - Set non-empty password for postgres tests [#398](https://github.com/gocardless/statesman/pull/#398)
19
- - Handle transitions differently for MySQL [#399](https://github.com/gocardless/statesman/pull/#399)
20
- - pg requirement from >= 0.18, <= 1.1 to >= 0.18, <= 1.3 [#400](https://github.com/gocardless/statesman/pull/#400)
21
- - Lazily enable mysql gaplock protection [#402](https://github.com/gocardless/statesman/pull/#402)
99
+ - Set non-empty password for postgres tests [#398](https://github.com/gocardless/statesman/pull/398)
100
+ - Handle transitions differently for MySQL [#399](https://github.com/gocardless/statesman/pull/399)
101
+ - pg requirement from >= 0.18, <= 1.1 to >= 0.18, <= 1.3 [#400](https://github.com/gocardless/statesman/pull/400)
102
+ - Lazily enable mysql gaplock protection [#402](https://github.com/gocardless/statesman/pull/402)
22
103
 
23
104
  ## v7.1.0, 10th Feb 2020
24
105
 
@@ -71,7 +152,7 @@
71
152
  to
72
153
  ```ruby
73
154
  include Statesman::Adapters::ActiveRecordQueries[
74
- initial_state: :inital,
155
+ initial_state: :initial,
75
156
  transition_class: MyTransition
76
157
  ]
77
158
  ```
data/CONTRIBUTING.md CHANGED
@@ -19,3 +19,21 @@ request passes by running `rubocop`.
19
19
 
20
20
  Please add a section to the readme for any new feature additions or behaviour
21
21
  changes.
22
+
23
+ ## Releasing
24
+
25
+ We publish new versions of Stateman using [RubyGems](https://guides.rubygems.org/publishing/). Once
26
+ the relevant changes have been merged and `VERSION` has been appropriately bumped to the new
27
+ version, we run the following command.
28
+ ```
29
+ $ gem build statesman.gemspec
30
+ ```
31
+ This builds a `.gem` file locally that will be named something like `statesman-X` where `X` is the
32
+ new version. For example, if we are releasing version 9.0.0, the file would be
33
+ `statesman-9.0.0.gem`.
34
+
35
+ To publish, run `gem push` with the new `.gem` file we just generated. This requires a OTP that is currently only available
36
+ to GoCardless engineers. For example, if we were to continue to publish version 9.0.0, we would run:
37
+ ```
38
+ $ gem push statesman-9.0.0.gem
39
+ ```
data/Gemfile CHANGED
@@ -4,15 +4,13 @@ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
- # rubocop:disable Bundler/DuplicatedGem
8
- if ENV['RAILS_VERSION'] == 'master'
9
- gem "rails", git: "https://github.com/rails/rails"
7
+ if ENV['RAILS_VERSION'] == 'main'
8
+ gem "rails", git: "https://github.com/rails/rails", branch: "main"
10
9
  elsif ENV['RAILS_VERSION']
11
10
  gem "rails", "~> #{ENV['RAILS_VERSION']}"
12
11
  end
13
- # rubocop:enable Bundler/DuplicatedGem
14
-
15
12
  group :development do
16
13
  # test/unit is no longer bundled with Ruby 2.2, but required by Rails
14
+ gem "pry"
17
15
  gem "test-unit", "~> 3.3" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.2.0")
18
16
  end