Sha256: 9f1722be10043d744df57dd933e550eddc44ec92e27e4288c6a023b733e4083a

Contents?: true

Size: 922 Bytes

Versions: 16

Compression:

Stored size: 922 Bytes

Contents

require_relative 'test_helper'

class MachineWithEventAttributesOnCustomActionTest < BaseTestCase
  def setup
    @superclass = new_model do
      def persist
        create_or_update
      end
    end
    @model = Class.new(@superclass)
    @machine = StateMachines::Machine.new(@model, :action => :persist)
    @machine.event :ignite do
      transition :parked => :idling
    end

    @record = @model.new
    @record.state = 'parked'
    @record.state_event = 'ignite'
  end

  def test_should_not_transition_on_valid?
    @record.valid?
    assert_equal 'parked', @record.state
  end

  def test_should_not_transition_on_save
    @record.save
    assert_equal 'parked', @record.state
  end

  def test_should_not_transition_on_save!
    @record.save!
    assert_equal 'parked', @record.state
  end

  def test_should_transition_on_custom_action
    @record.persist
    assert_equal 'idling', @record.state
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
state_machines-activerecord-0.9.0 test/machine_with_event_attributes_on_custom_action_test.rb
state_machines-activerecord-0.8.0 test/machine_with_event_attributes_on_custom_action_test.rb
state_machines-activerecord-0.6.0 test/machine_with_event_attributes_on_custom_action_test.rb
state_machines-activerecord-0.5.2 test/machine_with_event_attributes_on_custom_action_test.rb
state_machines-activerecord-0.5.1 test/machine_with_event_attributes_on_custom_action_test.rb
state_machines-activerecord-0.5.0 test/machine_with_event_attributes_on_custom_action_test.rb
state_machines-activerecord-0.4.1 test/machine_with_event_attributes_on_custom_action_test.rb
state_machines-activerecord-0.4.0 test/machine_with_event_attributes_on_custom_action_test.rb
state_machines-activerecord-0.4.0.pre test/machine_with_event_attributes_on_custom_action_test.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/state_machines-activerecord-0.2.0/test/machine_with_event_attributes_on_custom_action_test.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/state_machines-activerecord-0.2.0/test/machine_with_event_attributes_on_custom_action_test.rb
state_machines-activerecord-0.3.0 test/machine_with_event_attributes_on_custom_action_test.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/state_machines-activerecord-0.2.0/test/machine_with_event_attributes_on_custom_action_test.rb
state_machines-activerecord-0.2.0 test/machine_with_event_attributes_on_custom_action_test.rb
state_machines-activerecord-0.1.0 test/machine_with_event_attributes_on_custom_action_test.rb
state_machines-activerecord-0.0.1 test/machine_with_event_attributes_on_custom_action_test.rb