rails_state_machine 2.2.0 → 3.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f07991f6a0bc2dab134bc8518199885d79d0ee49d1865043a5e805e71c04b2b8
4
- data.tar.gz: b4d3ba7b43eaed7a95522df3b385147f6feefbfac8a7b9dd7c49c6089731d037
3
+ metadata.gz: 5461e8b6079aa65b23429567e03e5bcabb68ccb1887899d68de7102ac86ff120
4
+ data.tar.gz: 610999ac7316bbdd129614387e92a0898e8845406a40d72859f702e9addf24dd
5
5
  SHA512:
6
- metadata.gz: 1a5c81c9136fc6181974e7de5cd4a664f481c965098f39af45a3998b5cc3f29c9a46e0e983d5ca2cb724915505143c09643b93ade5a6bf3d47590af6ab716147
7
- data.tar.gz: af45d14e32f278bc0a4e1d1dc76b9f7863300e178d87b032f7217c7aa4df1987740a5fb895b055058b6fb7fb1ca4e08cc3021c2d6b2bafc62c44ac1f15f23d94
6
+ metadata.gz: b165ba8d60b65d476d1319e4572bdddc236a0f02fe6c6ea9c9565de3fbd48ea1d6fe36562aa10002949d22ba7805b9d7ca83c433135ab57fc231e87dacd4235f
7
+ data.tar.gz: 56f440e86a4c264b831ad37e4e33196eaf739a3f262dfb68d9bb2a0907aef09943085e2355129526352aa02da0f623e2559591ddddcc6e23b42693b7019893aa
@@ -9,10 +9,10 @@ name: Tests
9
9
  - master
10
10
  jobs:
11
11
  test_pg:
12
- runs-on: ubuntu-20.04
12
+ runs-on: ubuntu-22.04
13
13
  services:
14
14
  postgres:
15
- image: postgres:9.3
15
+ image: postgres:14.15
16
16
  env:
17
17
  POSTGRES_PASSWORD: postgres
18
18
  options: "--health-cmd pg_isready --health-interval 10s --health-timeout 5s
@@ -25,25 +25,47 @@ jobs:
25
25
  include:
26
26
  - ruby: 2.5.6
27
27
  gemfile: Gemfile.5.2.pg
28
+ bundler: 2.3.0
28
29
  - ruby: 2.5.6
29
30
  gemfile: Gemfile.6.0.pg
31
+ bundler: 2.3.11
30
32
 
31
33
  - ruby: 2.6.6
32
34
  gemfile: Gemfile.5.2.pg
35
+ bundler: 2.3.0
33
36
  - ruby: 2.6.6
34
37
  gemfile: Gemfile.6.0.pg
38
+ bundler: 2.3.11
35
39
 
36
40
  - ruby: 2.7.2
37
41
  gemfile: Gemfile.6.0.pg
42
+ bundler: 2.3.11
38
43
  - ruby: 2.7.2
39
44
  gemfile: Gemfile.6.1.pg
45
+ bundler: 2.2.25
40
46
  - ruby: 2.7.2
41
47
  gemfile: Gemfile.7.0.pg
48
+ bundler: 2.3.0
42
49
 
43
- - ruby: 3.0.0
50
+ - ruby: 3.2.0
44
51
  gemfile: Gemfile.6.1.pg
45
- - ruby: 3.0.0
52
+ bundler: 2.2.25
53
+ - ruby: 3.2.0
46
54
  gemfile: Gemfile.7.0.pg
55
+ bundler: 2.3.0
56
+ - ruby: 3.2.0
57
+ gemfile: Gemfile.8.0.pg
58
+ bundler: 2.5.23
59
+
60
+ - ruby: 3.4.1
61
+ gemfile: Gemfile.6.1.pg
62
+ bundler: 2.5.23
63
+ - ruby: 3.4.1
64
+ gemfile: Gemfile.7.0.pg
65
+ bundler: 2.5.23
66
+ - ruby: 3.4.1
67
+ gemfile: Gemfile.8.0.pg
68
+ bundler: 2.5.23
47
69
  env:
48
70
  BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
49
71
  steps:
@@ -58,7 +80,7 @@ jobs:
58
80
  PGPASSWORD=postgres psql -c 'create database rails_state_machine_test;' -U postgres -p 5432 -h localhost
59
81
  - name: Bundle
60
82
  run: |
61
- gem install bundler:2.1.4
62
- bundle install --no-deployment
83
+ gem install bundler:${{ matrix.bundler }}
84
+ bundle _${{ matrix.bundler }}_ install --no-deployment
63
85
  - name: Run tests
64
- run: bundle exec rspec
86
+ run: bundle _${{ matrix.bundler }}_ exec rspec
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.4.6
1
+ 3.4.1
data/CHANGELOG.md CHANGED
@@ -9,6 +9,69 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
9
9
 
10
10
  ### Breaking changes
11
11
 
12
+ ## 3.1.0 2025-01-21
13
+
14
+ ### Compatible changes
15
+
16
+ - Added support for Ruby 3.4
17
+
18
+ ## 3.0.0 2024-06-21
19
+
20
+ ### Breaking changes
21
+
22
+ - Changed: Setting the `<state_name>_event` to an invalid event adds an error to the attribute instead of raising a `TransitionNotFoundError` error.
23
+ - Changed: Calling `<event_name>` with an invalid event adds an error to the `<state_name>_event` attribute instead of raising a `TransitionNotFoundError` error.
24
+ - Changed: Calling `<event_name>!` with an invalid event adds an error to the `<state_name>_event` attribute an raises a `ActiveRecord::RecordInvalid` error instead of a `TransitionNotFoundError` error.
25
+ - Changed: The `<state_name>_event` type was changed to `ActiveModel::Attributes`.
26
+ - Changed: `#find_event` returns `nil` in case the event is missing, previously it raised a `KeyError` error.
27
+ - Changed: The transition of a `<state_name>_event` is executed in a prepended `before_validation` callback. If the transition is possible, the `<state_attribute>` is changed and the `<state_name>_event` is set to `nil` afterwards. If the transition is not possible, the `<state_attribute>` is not changed and the `<state_name>_event` keeps the set value.
28
+
29
+ Before:
30
+
31
+ ```ruby
32
+ order.update(state_event: 'finish') # => RailsStateMachine::Event::TransitionNotFoundError
33
+ order.finish # => RailsStateMachine::Event::TransitionNotFoundError
34
+ order.finish! # => RailsStateMachine::Event::TransitionNotFoundError
35
+ ```
36
+
37
+ After:
38
+
39
+ ```ruby
40
+ order.update(state_event: 'finish') # => false (state_event has the error :invalid)
41
+ order.finish # => false (state_event has the error :invalid)
42
+ order.finish! # => ActiveRecord::RecordInvalid (state_event has the error :invalid)
43
+ ```
44
+
45
+ Upgrade examples:
46
+
47
+ ```ruby
48
+ # Before the upgrade you might have rescued RailsStateMachine::Event::TransitionNotFoundError in e.g. a controller
49
+ def update
50
+ build_user
51
+ if @user.save
52
+ flash[:success] = 'User saved!'
53
+ redirect_to @user
54
+ else
55
+ flash.now[:error] = 'User could not be saved!'
56
+ render(:edit, status: :unprocessable_entity)
57
+ end
58
+ rescue RailsStateMachine::Event::TransitionNotFoundError
59
+ flash.now[:error] = 'State event not valid anymore, maybe reload the page?'
60
+ render(:edit, status: :unprocessable_entity)
61
+ end
62
+
63
+ # After upgrade you can either show a flash message or show an error message in your view for the <state>_event attribute
64
+ def update
65
+ build_user
66
+ if @user.save
67
+ flash[:success] = 'User saved!'
68
+ redirect_to @user
69
+ else
70
+ flash.now[:error] = @user.errors.include?(:state_event) ? 'State event not valid anymore, maybe reload the page?' : 'User could not be saved!'
71
+ render(:edit, status: :unprocessable_entity)
72
+ end
73
+ end
74
+ ```
12
75
 
13
76
  ## 2.2.0 2023-12-06
14
77
 
data/Gemfile CHANGED
@@ -1 +1 @@
1
- ./Gemfile.5.1.pg
1
+ Gemfile.8.0.pg
data/Gemfile.5.2.pg CHANGED
@@ -7,8 +7,8 @@ gem 'pg'
7
7
  # Development dependencies
8
8
  gem 'rspec', '~>3.5'
9
9
  gem 'rake'
10
- gem 'pry-byebug'
11
- gem 'gemika'
10
+ gem 'pry'
11
+ gem 'gemika', '>= 0.8.1'
12
12
  gem 'database_cleaner'
13
13
 
14
14
  # Gem under test
data/Gemfile.5.2.pg.lock CHANGED
@@ -1,155 +1,175 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_state_machine (2.2.0)
4
+ rails_state_machine (3.1.0)
5
5
  activerecord
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (5.2.1)
11
- actionpack (= 5.2.1)
10
+ actioncable (5.2.8.1)
11
+ actionpack (= 5.2.8.1)
12
12
  nio4r (~> 2.0)
13
13
  websocket-driver (>= 0.6.1)
14
- actionmailer (5.2.1)
15
- actionpack (= 5.2.1)
16
- actionview (= 5.2.1)
17
- activejob (= 5.2.1)
14
+ actionmailer (5.2.8.1)
15
+ actionpack (= 5.2.8.1)
16
+ actionview (= 5.2.8.1)
17
+ activejob (= 5.2.8.1)
18
18
  mail (~> 2.5, >= 2.5.4)
19
19
  rails-dom-testing (~> 2.0)
20
- actionpack (5.2.1)
21
- actionview (= 5.2.1)
22
- activesupport (= 5.2.1)
23
- rack (~> 2.0)
20
+ actionpack (5.2.8.1)
21
+ actionview (= 5.2.8.1)
22
+ activesupport (= 5.2.8.1)
23
+ rack (~> 2.0, >= 2.0.8)
24
24
  rack-test (>= 0.6.3)
25
25
  rails-dom-testing (~> 2.0)
26
26
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
- actionview (5.2.1)
28
- activesupport (= 5.2.1)
27
+ actionview (5.2.8.1)
28
+ activesupport (= 5.2.8.1)
29
29
  builder (~> 3.1)
30
30
  erubi (~> 1.4)
31
31
  rails-dom-testing (~> 2.0)
32
32
  rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
- activejob (5.2.1)
34
- activesupport (= 5.2.1)
33
+ activejob (5.2.8.1)
34
+ activesupport (= 5.2.8.1)
35
35
  globalid (>= 0.3.6)
36
- activemodel (5.2.1)
37
- activesupport (= 5.2.1)
38
- activerecord (5.2.1)
39
- activemodel (= 5.2.1)
40
- activesupport (= 5.2.1)
36
+ activemodel (5.2.8.1)
37
+ activesupport (= 5.2.8.1)
38
+ activerecord (5.2.8.1)
39
+ activemodel (= 5.2.8.1)
40
+ activesupport (= 5.2.8.1)
41
41
  arel (>= 9.0)
42
- activestorage (5.2.1)
43
- actionpack (= 5.2.1)
44
- activerecord (= 5.2.1)
45
- marcel (~> 0.3.1)
46
- activesupport (5.2.1)
42
+ activestorage (5.2.8.1)
43
+ actionpack (= 5.2.8.1)
44
+ activerecord (= 5.2.8.1)
45
+ marcel (~> 1.0.0)
46
+ activesupport (5.2.8.1)
47
47
  concurrent-ruby (~> 1.0, >= 1.0.2)
48
48
  i18n (>= 0.7, < 2)
49
49
  minitest (~> 5.1)
50
50
  tzinfo (~> 1.1)
51
51
  arel (9.0.0)
52
- builder (3.2.3)
53
- byebug (10.0.2)
54
- coderay (1.1.2)
55
- concurrent-ruby (1.0.5)
56
- crass (1.0.4)
57
- database_cleaner (1.7.0)
58
- diff-lcs (1.3)
59
- erubi (1.7.1)
60
- gemika (0.5.0)
61
- globalid (0.4.1)
62
- activesupport (>= 4.2.0)
63
- i18n (1.1.0)
52
+ builder (3.3.0)
53
+ coderay (1.1.3)
54
+ concurrent-ruby (1.3.3)
55
+ crass (1.0.6)
56
+ database_cleaner (2.0.2)
57
+ database_cleaner-active_record (>= 2, < 3)
58
+ database_cleaner-active_record (2.1.0)
59
+ activerecord (>= 5.a)
60
+ database_cleaner-core (~> 2.0.0)
61
+ database_cleaner-core (2.0.1)
62
+ diff-lcs (1.5.1)
63
+ digest (3.1.1)
64
+ erubi (1.13.0)
65
+ gemika (0.8.3)
66
+ globalid (1.1.0)
67
+ activesupport (>= 5.0)
68
+ i18n (1.14.5)
64
69
  concurrent-ruby (~> 1.0)
65
- loofah (2.2.2)
70
+ io-wait (0.3.1)
71
+ loofah (2.22.0)
66
72
  crass (~> 1.0.2)
67
- nokogiri (>= 1.5.9)
68
- mail (2.7.0)
73
+ nokogiri (>= 1.12.0)
74
+ mail (2.8.1)
69
75
  mini_mime (>= 0.1.1)
70
- marcel (0.3.2)
71
- mimemagic (~> 0.3.2)
72
- method_source (0.9.0)
73
- mimemagic (0.3.10)
74
- nokogiri (~> 1)
75
- rake
76
- mini_mime (1.0.1)
77
- mini_portile2 (2.3.0)
78
- minitest (5.11.3)
79
- nio4r (2.3.1)
80
- nokogiri (1.8.4)
81
- mini_portile2 (~> 2.3.0)
82
- pg (1.1.2)
83
- pry (0.11.3)
84
- coderay (~> 1.1.0)
85
- method_source (~> 0.9.0)
86
- pry-byebug (3.6.0)
87
- byebug (~> 10.0)
88
- pry (~> 0.10)
89
- rack (2.0.5)
90
- rack-test (1.1.0)
91
- rack (>= 1.0, < 3)
92
- rails (5.2.1)
93
- actioncable (= 5.2.1)
94
- actionmailer (= 5.2.1)
95
- actionpack (= 5.2.1)
96
- actionview (= 5.2.1)
97
- activejob (= 5.2.1)
98
- activemodel (= 5.2.1)
99
- activerecord (= 5.2.1)
100
- activestorage (= 5.2.1)
101
- activesupport (= 5.2.1)
76
+ net-imap
77
+ net-pop
78
+ net-smtp
79
+ marcel (1.0.4)
80
+ method_source (1.1.0)
81
+ mini_mime (1.1.2)
82
+ mini_portile2 (2.6.1)
83
+ minitest (5.15.0)
84
+ net-imap (0.2.2)
85
+ digest
86
+ net-protocol
87
+ strscan
88
+ net-pop (0.1.2)
89
+ net-protocol
90
+ net-protocol (0.1.2)
91
+ io-wait
92
+ timeout
93
+ net-smtp (0.3.0)
94
+ digest
95
+ net-protocol
96
+ timeout
97
+ nio4r (2.7.3)
98
+ nokogiri (1.12.5)
99
+ mini_portile2 (~> 2.6.1)
100
+ racc (~> 1.4)
101
+ pg (1.5.6)
102
+ pry (0.14.2)
103
+ coderay (~> 1.1)
104
+ method_source (~> 1.0)
105
+ racc (1.8.0)
106
+ rack (2.2.9)
107
+ rack-test (2.1.0)
108
+ rack (>= 1.3)
109
+ rails (5.2.8.1)
110
+ actioncable (= 5.2.8.1)
111
+ actionmailer (= 5.2.8.1)
112
+ actionpack (= 5.2.8.1)
113
+ actionview (= 5.2.8.1)
114
+ activejob (= 5.2.8.1)
115
+ activemodel (= 5.2.8.1)
116
+ activerecord (= 5.2.8.1)
117
+ activestorage (= 5.2.8.1)
118
+ activesupport (= 5.2.8.1)
102
119
  bundler (>= 1.3.0)
103
- railties (= 5.2.1)
120
+ railties (= 5.2.8.1)
104
121
  sprockets-rails (>= 2.0.0)
105
- rails-dom-testing (2.0.3)
106
- activesupport (>= 4.2.0)
122
+ rails-dom-testing (2.2.0)
123
+ activesupport (>= 5.0.0)
124
+ minitest
107
125
  nokogiri (>= 1.6)
108
- rails-html-sanitizer (1.0.4)
109
- loofah (~> 2.2, >= 2.2.2)
110
- railties (5.2.1)
111
- actionpack (= 5.2.1)
112
- activesupport (= 5.2.1)
126
+ rails-html-sanitizer (1.5.0)
127
+ loofah (~> 2.19, >= 2.19.1)
128
+ railties (5.2.8.1)
129
+ actionpack (= 5.2.8.1)
130
+ activesupport (= 5.2.8.1)
113
131
  method_source
114
132
  rake (>= 0.8.7)
115
133
  thor (>= 0.19.0, < 2.0)
116
- rake (12.3.1)
117
- rspec (3.8.0)
118
- rspec-core (~> 3.8.0)
119
- rspec-expectations (~> 3.8.0)
120
- rspec-mocks (~> 3.8.0)
121
- rspec-core (3.8.0)
122
- rspec-support (~> 3.8.0)
123
- rspec-expectations (3.8.1)
134
+ rake (13.2.1)
135
+ rspec (3.13.0)
136
+ rspec-core (~> 3.13.0)
137
+ rspec-expectations (~> 3.13.0)
138
+ rspec-mocks (~> 3.13.0)
139
+ rspec-core (3.13.0)
140
+ rspec-support (~> 3.13.0)
141
+ rspec-expectations (3.13.1)
124
142
  diff-lcs (>= 1.2.0, < 2.0)
125
- rspec-support (~> 3.8.0)
126
- rspec-mocks (3.8.0)
143
+ rspec-support (~> 3.13.0)
144
+ rspec-mocks (3.13.1)
127
145
  diff-lcs (>= 1.2.0, < 2.0)
128
- rspec-support (~> 3.8.0)
129
- rspec-support (3.8.0)
130
- sprockets (3.7.2)
146
+ rspec-support (~> 3.13.0)
147
+ rspec-support (3.13.1)
148
+ sprockets (4.2.1)
131
149
  concurrent-ruby (~> 1.0)
132
- rack (> 1, < 3)
133
- sprockets-rails (3.2.1)
134
- actionpack (>= 4.0)
135
- activesupport (>= 4.0)
150
+ rack (>= 2.2.4, < 4)
151
+ sprockets-rails (3.4.2)
152
+ actionpack (>= 5.2)
153
+ activesupport (>= 5.2)
136
154
  sprockets (>= 3.0.0)
137
- thor (0.20.0)
155
+ strscan (3.1.0)
156
+ thor (1.2.2)
138
157
  thread_safe (0.3.6)
139
- tzinfo (1.2.5)
158
+ timeout (0.4.0)
159
+ tzinfo (1.2.11)
140
160
  thread_safe (~> 0.1)
141
- websocket-driver (0.7.0)
161
+ websocket-driver (0.7.6)
142
162
  websocket-extensions (>= 0.1.0)
143
- websocket-extensions (0.1.3)
163
+ websocket-extensions (0.1.5)
144
164
 
145
165
  PLATFORMS
146
166
  ruby
147
167
 
148
168
  DEPENDENCIES
149
169
  database_cleaner
150
- gemika
170
+ gemika (>= 0.8.1)
151
171
  pg
152
- pry-byebug
172
+ pry
153
173
  rails (~> 5.2.0)
154
174
  rails_state_machine!
155
175
  rake
data/Gemfile.6.0.pg CHANGED
@@ -7,8 +7,8 @@ gem 'pg'
7
7
  # Development dependencies
8
8
  gem 'rspec', '~>3.5'
9
9
  gem 'rake'
10
- gem 'pry-byebug'
11
- gem 'gemika'
10
+ gem 'pry'
11
+ gem 'gemika', '>= 0.8.1'
12
12
  gem 'database_cleaner'
13
13
 
14
14
  # Gem under test