aasm 5.3.0 → 5.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +2 -0
- data/CHANGELOG.md +5 -0
- data/lib/aasm/errors.rb +1 -0
- data/lib/aasm/instance_base.rb +4 -3
- data/lib/aasm/version.rb +1 -1
- data/spec/spec_helpers/mongoid.rb +1 -0
- data/spec/unit/callbacks_spec.rb +2 -2
- data/spec/unit/complex_example_spec.rb +2 -2
- data/spec/unit/event_spec.rb +25 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ec8cfc1d821c4acb9bd0ce3f3af83174f28314f4f9c91f511d2a77555faf731
|
4
|
+
data.tar.gz: 8ed85be2d9cee794e3738349ba567667946b5df80ded58a5bd009d864b99fc02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19ecf2a0254280ecbcacee23b7f671d4a5fefc5cc0bf4eabffd5fc98e1bff648b35048a201d4f60e22b6ca989ca03dd958f8ff558ee8c62c2662b83d994b9692
|
7
|
+
data.tar.gz: afe81dea0198b16bfbac59293625b1ab7aa94a62f1250511a7e03957d71724f52b1a01e5c01d48d3bf04c53013578a5ffae8859b9134212137b1aadd4285b894
|
data/.github/workflows/build.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
3
|
## unreleased
|
4
|
+
## 5.3.1
|
5
|
+
* Fix fire! with string argument [#787](https://github.com/aasm/aasm/issues/787), in PR[#788](https://github.com/aasm/aasm/pull/788) thanks to [norman](https://github.com/norman)
|
6
|
+
|
7
|
+
* Allow `fire` and `fire!` to accept a String or Symbol for the event name, and raise AASM::UndefinedEvent rather than AASM::UndefinedState
|
8
|
+
when an event can not be found, thanks to [norman](https://github.com/norman).
|
4
9
|
|
5
10
|
## 5.3.0
|
6
11
|
|
data/lib/aasm/errors.rb
CHANGED
data/lib/aasm/instance_base.rb
CHANGED
@@ -134,10 +134,11 @@ module AASM
|
|
134
134
|
private
|
135
135
|
|
136
136
|
def event_exists?(event_name, bang = false)
|
137
|
-
event = @instance.class.aasm(@name).state_machine.events[event_name]
|
138
|
-
|
137
|
+
event = @instance.class.aasm(@name).state_machine.events[event_name.to_sym]
|
138
|
+
return true if event
|
139
139
|
|
140
|
-
|
140
|
+
event_error = bang ? "#{event_name}!" : event_name
|
141
|
+
raise AASM::UndefinedEvent, "Event :#{event_error} doesn't exist" if event.nil?
|
141
142
|
end
|
142
143
|
end
|
143
144
|
end
|
data/lib/aasm/version.rb
CHANGED
data/spec/unit/callbacks_spec.rb
CHANGED
@@ -153,11 +153,11 @@ describe 'callbacks for the new DSL' do
|
|
153
153
|
|
154
154
|
expect {
|
155
155
|
callback.aasm.fire(:unknown)
|
156
|
-
}.to raise_error(AASM::
|
156
|
+
}.to raise_error(AASM::UndefinedEvent, "Event :unknown doesn't exist")
|
157
157
|
|
158
158
|
expect {
|
159
159
|
callback.aasm.fire!(:unknown)
|
160
|
-
}.to raise_error(AASM::
|
160
|
+
}.to raise_error(AASM::UndefinedEvent, "Event :unknown! doesn't exist")
|
161
161
|
end
|
162
162
|
|
163
163
|
it "does not run any state callback if the event guard fails" do
|
@@ -92,10 +92,10 @@ describe 'when being unsuspended' do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should raise AASM::UndefinedState when firing unknown events" do
|
95
|
-
expect { auth.aasm.fire(:unknown) }.to raise_error(AASM::
|
95
|
+
expect { auth.aasm.fire(:unknown) }.to raise_error(AASM::UndefinedEvent, "Event :unknown doesn't exist")
|
96
96
|
end
|
97
97
|
|
98
98
|
it "should raise AASM::UndefinedState when firing unknown bang events" do
|
99
|
-
expect { auth.aasm.fire!(:unknown) }.to raise_error(AASM::
|
99
|
+
expect { auth.aasm.fire!(:unknown) }.to raise_error(AASM::UndefinedEvent, "Event :unknown! doesn't exist")
|
100
100
|
end
|
101
101
|
end
|
data/spec/unit/event_spec.rb
CHANGED
@@ -296,15 +296,32 @@ describe 'current event' do
|
|
296
296
|
end
|
297
297
|
|
298
298
|
describe "when calling events with fire/fire!" do
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
299
|
+
context "fire" do
|
300
|
+
it "should populate aasm.current_event and transition (sleeping to showering)" do
|
301
|
+
pe.aasm.fire(:wakeup)
|
302
|
+
expect(pe.aasm.current_event).to eq :wakeup
|
303
|
+
expect(pe.aasm.current_state).to eq :showering
|
304
|
+
end
|
305
|
+
|
306
|
+
it "should allow event names as strings" do
|
307
|
+
pe.aasm.fire("wakeup")
|
308
|
+
expect(pe.aasm.current_event).to eq :wakeup
|
309
|
+
expect(pe.aasm.current_state).to eq :showering
|
310
|
+
end
|
303
311
|
end
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
312
|
+
|
313
|
+
context "fire!" do
|
314
|
+
it "should populate aasm.current_event and transition (sleeping to showering)" do
|
315
|
+
pe.aasm.fire!(:wakeup)
|
316
|
+
expect(pe.aasm.current_event).to eq :wakeup!
|
317
|
+
expect(pe.aasm.current_state).to eq :showering
|
318
|
+
end
|
319
|
+
|
320
|
+
it "should allow event names as strings" do
|
321
|
+
pe.aasm.fire!("wakeup")
|
322
|
+
expect(pe.aasm.current_event).to eq :wakeup!
|
323
|
+
expect(pe.aasm.current_state).to eq :showering
|
324
|
+
end
|
308
325
|
end
|
309
326
|
end
|
310
327
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aasm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.3.
|
4
|
+
version: 5.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thorsten Boettger
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-09-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: concurrent-ruby
|