pluginaweek/state_machine — pull request #162 by joelind (2012-02-21 12:35:34+00:00)
Title: Do not call callbacks when they are disabled

Hi,

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] (https://github.com/myronmarston/rails/blob/d3c15a1d31d77e44b142c96cb55b654f3552a89d/activemodel/lib/active_model/observing.rb#L229).

Thanks!
-Joe