I've been using state_machine with ActiveRecord and in some instances am using ActiveRecord::Observers.disable to turn off observers (for instance, to isolate certain model behaviors during tests). state_machine's definition of Observer.update_with_transition does not check for disabled_for? before using the send method to call the callback.
I added test cases to the ActiveModel and ActiveRecord integration tests to test the behavior and changed the update_with_transition method to match the current implementation in ActiveModel itself.
Observe ActiveModel disabled_for? in callbacks
Hey @joelind -
Thanks for reporting this and providing a fix! As it turns out, the problem is that ActiveModel just isn't properly detecting the disabled list of observers on the object -- state_machine doesn't need to actually implement those checks. I've gone with a different implementation that should resolve this issue in the same manner.
Fix observer callbacks being run when disabled in ActiveModel / Activ…
…eRecord integrations. Closes #162