state-machines / state_machines

Adds support for creating state machines for attributes on any Ruby class
https://github.com/state-machines/state_machines
MIT License
814 stars 91 forks source link

State predicates should not override existing methods #74

Open magni- opened 4 years ago

magni- commented 4 years ago

When defining a state machine, Machine#define_state_predicate first checks to see whether the method it would add is already defined or not. However, when defining a state, State#add_predicate does no such check.

We had a machine with a destroyed check work fine until we started to upgrade to Rails 5.2, because that version of Rails adds a check for destroyed? in its create_or_update method.

Ideally, there would be a warning just like there is when defining a state already defined on another state machine on the same model.

edit: from this test case, it looks like this should already work?