class ActiveRecordTest::MachineWithEventAttributesOnCustomActionTest

Public Instance Methods

persist() click to toggle source
# File test/unit/integrations/active_record_test.rb, line 1485
def persist
  create_or_update
end
setup() click to toggle source
# File test/unit/integrations/active_record_test.rb, line 1483
def setup
  @superclass = new_model do
    def persist
      create_or_update
    end
  end
  @model = Class.new(@superclass)
  @machine = StateMachine::Machine.new(@model, :action => :persist)
  @machine.event :ignite do
    transition :parked => :idling
  end
  
  @record = @model.new
  @record.state = 'parked'
  @record.state_event = 'ignite'
end
test_should_not_transition_on_save() click to toggle source
# File test/unit/integrations/active_record_test.rb, line 1505
def test_should_not_transition_on_save
  @record.save
  assert_equal 'parked', @record.state
end
test_should_not_transition_on_save!() click to toggle source
# File test/unit/integrations/active_record_test.rb, line 1510
def test_should_not_transition_on_save!
  @record.save!
  assert_equal 'parked', @record.state
end
test_should_not_transition_on_valid?() click to toggle source
# File test/unit/integrations/active_record_test.rb, line 1500
def test_should_not_transition_on_valid?
  @record.valid?
  assert_equal 'parked', @record.state
end
test_should_transition_on_custom_action() click to toggle source
# File test/unit/integrations/active_record_test.rb, line 1515
def test_should_transition_on_custom_action
  @record.persist
  assert_equal 'idling', @record.state
end