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 +4 -4
- data/.github/workflows/test.yml +2 -2
- data/.ruby-version +1 -1
- data/CHANGELOG.md +57 -0
- data/Gemfile +1 -1
- data/Gemfile.5.2.pg +2 -2
- data/Gemfile.5.2.pg.lock +123 -103
- data/Gemfile.6.0.pg +2 -2
- data/Gemfile.6.0.pg.lock +140 -120
- data/Gemfile.6.1.pg +4 -4
- data/Gemfile.6.1.pg.lock +131 -119
- data/Gemfile.7.0.pg +6 -5
- data/Gemfile.7.0.pg.lock +112 -93
- data/Gemfile.lock +1 -1
- data/README.md +7 -2
- data/bin/console +1 -1
- data/lib/rails_state_machine/callbacks.rb +11 -0
- data/lib/rails_state_machine/state_machine.rb +5 -11
- data/lib/rails_state_machine/state_manager.rb +25 -7
- data/lib/rails_state_machine/version.rb +1 -1
- data/rails_state_machine.gemspec +0 -1
- metadata +3 -19
- data/Gemfile.5.1.pg +0 -15
- data/Gemfile.5.1.pg.lock +0 -149
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2a7ac60ccf566caaed843939ff8b81566eaf273dfbed9a6f8aa4ebc6f78b523
|
4
|
+
data.tar.gz: e625ae5c03f382a45fe8011c09d831cefbe0b9c44b1806e2b7f9dd265f3c3df8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07652ff7ef7916a95c1a57bab7ba4b21b8b64df6cebd28b2848f79d85d7bb8a2413180fa765d02c071985a36bb0d1ef706cba3d9af18d8834edb6fa642807f98
|
7
|
+
data.tar.gz: c3cecdfa2ad2fafe1f96e6435a28692f43dc08e1b63fbbcfd30678804072274c763fa3cc11cf934615f67149805d355431645514b71eebc7e7bab00ce0363d4c
|
data/.github/workflows/test.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
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
|
-
|
1
|
+
Gemfile.7.0.pg
|
data/Gemfile.5.2.pg
CHANGED
data/Gemfile.5.2.pg.lock
CHANGED
@@ -1,155 +1,175 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rails_state_machine (
|
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.
|
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.
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
-
|
70
|
+
io-wait (0.3.1)
|
71
|
+
loofah (2.22.0)
|
66
72
|
crass (~> 1.0.2)
|
67
|
-
nokogiri (>= 1.
|
68
|
-
mail (2.
|
73
|
+
nokogiri (>= 1.12.0)
|
74
|
+
mail (2.8.1)
|
69
75
|
mini_mime (>= 0.1.1)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
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
|
106
|
-
activesupport (>=
|
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
|
109
|
-
loofah (~> 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 (
|
117
|
-
rspec (3.
|
118
|
-
rspec-core (~> 3.
|
119
|
-
rspec-expectations (~> 3.
|
120
|
-
rspec-mocks (~> 3.
|
121
|
-
rspec-core (3.
|
122
|
-
rspec-support (~> 3.
|
123
|
-
rspec-expectations (3.
|
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.
|
126
|
-
rspec-mocks (3.
|
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.
|
129
|
-
rspec-support (3.
|
130
|
-
sprockets (
|
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 (
|
133
|
-
sprockets-rails (3.2
|
134
|
-
actionpack (>=
|
135
|
-
activesupport (>=
|
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
|
-
|
155
|
+
strscan (3.1.0)
|
156
|
+
thor (1.2.2)
|
138
157
|
thread_safe (0.3.6)
|
139
|
-
|
158
|
+
timeout (0.4.0)
|
159
|
+
tzinfo (1.2.11)
|
140
160
|
thread_safe (~> 0.1)
|
141
|
-
websocket-driver (0.7.
|
161
|
+
websocket-driver (0.7.6)
|
142
162
|
websocket-extensions (>= 0.1.0)
|
143
|
-
websocket-extensions (0.1.
|
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
|
172
|
+
pry
|
153
173
|
rails (~> 5.2.0)
|
154
174
|
rails_state_machine!
|
155
175
|
rake
|