#7 new
Nathaniel Bibler

State :exit called when all transitions fail

Reported by Nathaniel Bibler | September 19th, 2008 @ 12:22 AM

When defining an aasm_state with an :exit option, the defined exit method is currently executed even if all transitions fail:


class Foo
  include AASM
  aasm_initial_state :open
  aasm_state :open,   :exit => :exit
  aasm_state :closed

  aasm_event :null do
    transitions :to => :closed, :from => [:open], :guard => :always_false
  end

  def always_false
    false
  end

  def exit
  end
end

foo = Foo.new
foo.null # => executes foo.exit, even though the guard fails.

This is highly unexpected behavior. The exit method should only be executed during a successful event transition.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Library for adding state machines to Ruby classes. Includes persistence layers for things like ActiveRecord. Formerly known as acts_as_state_machine.

Attachments

Tags

Pages