1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00

may not fire an unknown event #128

This commit is contained in:
Thorsten Böttger 2014-05-16 21:57:18 +02:00
parent 2f31a6ed9a
commit c4b672046a
2 changed files with 14 additions and 2 deletions

View file

@ -75,8 +75,11 @@ module AASM
end
def may_fire_event?(name, *args)
event = @instance.class.aasm.events[name]
event.may_fire?(@instance, *args)
if event = @instance.class.aasm.events[name]
event.may_fire?(@instance, *args)
else
false # unknown event
end
end
def set_current_state_with_persistence(state)

View file

@ -72,4 +72,13 @@ describe 'when being unsuspended' do
expect(auth.aasm.current_state).to eq(:passive)
end
it "should be able to fire known events" do
expect(auth.aasm.may_fire_event?(:activate)).to be_true
end
it "should not be able to fire unknown events" do
expect(auth.aasm.may_fire_event?(:unknown)).to be_false
end
end