rails_state_machine 2.2.0 → 3.0.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: d2a7ac60ccf566caaed843939ff8b81566eaf273dfbed9a6f8aa4ebc6f78b523
4
+ data.tar.gz: e625ae5c03f382a45fe8011c09d831cefbe0b9c44b1806e2b7f9dd265f3c3df8
5
5
  SHA512:
6
- metadata.gz: 1a5c81c9136fc6181974e7de5cd4a664f481c965098f39af45a3998b5cc3f29c9a46e0e983d5ca2cb724915505143c09643b93ade5a6bf3d47590af6ab716147
7
- data.tar.gz: af45d14e32f278bc0a4e1d1dc76b9f7863300e178d87b032f7217c7aa4df1987740a5fb895b055058b6fb7fb1ca4e08cc3021c2d6b2bafc62c44ac1f15f23d94
6
+ metadata.gz: 07652ff7ef7916a95c1a57bab7ba4b21b8b64df6cebd28b2848f79d85d7bb8a2413180fa765d02c071985a36bb0d1ef706cba3d9af18d8834edb6fa642807f98
7
+ data.tar.gz: c3cecdfa2ad2fafe1f96e6435a28692f43dc08e1b63fbbcfd30678804072274c763fa3cc11cf934615f67149805d355431645514b71eebc7e7bab00ce0363d4c
@@ -40,9 +40,9 @@ jobs:
40
40
  - ruby: 2.7.2
41
41
  gemfile: Gemfile.7.0.pg
42
42
 
43
- - ruby: 3.0.0
43
+ - ruby: 3.2.0
44
44
  gemfile: Gemfile.6.1.pg
45
- - ruby: 3.0.0
45
+ - ruby: 3.2.0
46
46
  gemfile: Gemfile.7.0.pg
47
47
  env:
48
48
  BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.4.6
1
+ 3.2.0
data/CHANGELOG.md CHANGED
@@ -9,6 +9,63 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
9
9
 
10
10
  ### Breaking changes
11
11
 
12
+ ## 3.0.0 2024-06-21
13
+
14
+ ### Breaking changes
15
+
16
+ - Changed: Setting the `<state_name>_event` to an invalid event adds an error to the attribute instead of raising a `TransitionNotFoundError` error.
17
+ - Changed: Calling `<event_name>` with an invalid event adds an error to the `<state_name>_event` attribute instead of raising a `TransitionNotFoundError` error.
18
+ - 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.
19
+ - Changed: The `<state_name>_event` type was changed to `ActiveModel::Attributes`.
20
+ - Changed: `#find_event` returns `nil` in case the event is missing, previously it raised a `KeyError` error.
21
+ - 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.
22
+
23
+ Before:
24
+
25
+ ```ruby
26
+ order.update(state_event: 'finish') # => RailsStateMachine::Event::TransitionNotFoundError
27
+ order.finish # => RailsStateMachine::Event::TransitionNotFoundError
28
+ order.finish! # => RailsStateMachine::Event::TransitionNotFoundError
29
+ ```
30
+
31
+ After:
32
+
33
+ ```ruby
34
+ order.update(state_event: 'finish') # => false (state_event has the error :invalid)
35
+ order.finish # => false (state_event has the error :invalid)
36
+ order.finish! # => ActiveRecord::RecordInvalid (state_event has the error :invalid)
37
+ ```
38
+
39
+ Upgrade examples:
40
+
41
+ ```ruby
42
+ # Before the upgrade you might have rescued RailsStateMachine::Event::TransitionNotFoundError in e.g. a controller
43
+ def update
44
+ build_user
45
+ if @user.save
46
+ flash[:success] = 'User saved!'
47
+ redirect_to @user
48
+ else
49
+ flash.now[:error] = 'User could not be saved!'
50
+ render(:edit, status: :unprocessable_entity)
51
+ end
52
+ rescue RailsStateMachine::Event::TransitionNotFoundError
53
+ flash.now[:error] = 'User could not be saved!'
54
+ render(:edit, status: :unprocessable_entity)
55
+ end
56
+
57
+ # After upgrade you can either show a flash message or show an error message in your view for the <state>_event attribute
58
+ def update
59
+ build_user
60
+ if @user.save
61
+ flash[:success] = 'User saved!'
62
+ redirect_to @user
63
+ else
64
+ flash.now[:error] = @user.errors.include?(:state_event) ? 'State event not valid anymore, maybe reload the page?' : 'User could not be saved!'
65
+ render(:edit, status: :unprocessable_entity)
66
+ end
67
+ end
68
+ ```
12
69
 
13
70
  ## 2.2.0 2023-12-06
14
71
 
data/Gemfile CHANGED
@@ -1 +1 @@
1
- ./Gemfile.5.1.pg
1
+ Gemfile.7.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.0.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