fire! and fire with unknown event, crash with NoMethodError
When I run fire or fire! with an unknown event (i.e. Model.aasm.fire!(:whatever) ) it raises a NoMethodError (undefined method fire_callbacks' for nil:NilClass), seems that it tries to fire before callbacks even not knowing that the event exists, which is not the expected behaviour.
For me, fire and fire! with an unknown event should not fire callbacks and return an exception like "Unknown event", to be consistent.
I agree with your point, are you interested in raising a PR for this ?
Yes, I'll do it :) Regarding before callbacks, I'm not sure if they should be triggered or not for an unknown event. How do we handle this case? do we consider the same behaviour for firing a non permitted event than for firing an unknown event, in terms of triggering callbacks?
For me an unpermitted event should trigger before callbacks, but not an unknown event.
What do you think @anilmaurya?
I Agree, unpermitted event should trigger before callbacks but unknown event should not trigger callbacks.
this should be fixed, as it is possible to call arbitrary methods:
Car.aasm.fire("destroy")
@mck9 'should be fixed' meaning no longer a problem, or that you would like it to be fixed? I suspect the latter.
@anilmaurya was there anything wrong with the PR looks like it's been hanging around for a year?
@barisbalic yes, the latter would be nice. fire should only be allowed to call valid events.