Sha256: 2d3b6a9ab2f3eb6135143f2b7d0eb6de4f588ce18d41ce3e3762bb3f1018d5da

Contents?: true

Size: 691 Bytes

Versions: 14

Compression:

Stored size: 691 Bytes

Contents

require_relative '../../test_helper'

class TransitionWithCustomMachineAttributeTest < StateMachinesTest
  def setup
    @klass = Class.new
    @machine = StateMachines::Machine.new(@klass, :state, attribute: :state_id)
    @machine.state :off, value: 1
    @machine.state :active, value: 2
    @machine.event :activate

    @object = @klass.new
    @object.state_id = 1

    @transition = StateMachines::Transition.new(@object, @machine, :activate, :off, :active)
  end

  def test_should_persist
    @transition.persist
    assert_equal 2, @object.state_id
  end

  def test_should_rollback
    @object.state_id = 2
    @transition.rollback

    assert_equal 1, @object.state_id
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
state_machines-0.5.0 test/unit/transition/transition_with_custom_machine_attribute_test.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/state_machines-0.2.2/test/unit/transition/transition_with_custom_machine_attribute_test.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/state_machines-0.2.2/test/unit/transition/transition_with_custom_machine_attribute_test.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/state_machines-0.2.2/test/unit/transition/transition_with_custom_machine_attribute_test.rb
state_machines-0.4.0 test/unit/transition/transition_with_custom_machine_attribute_test.rb
state_machines-0.3.0 test/unit/transition/transition_with_custom_machine_attribute_test.rb
state_machines-0.2.2 test/unit/transition/transition_with_custom_machine_attribute_test.rb
state_machines-0.2.1 test/unit/transition/transition_with_custom_machine_attribute_test.rb
state_machines-0.2.0 test/unit/transition/transition_with_custom_machine_attribute_test.rb
state_machines-0.1.4 test/unit/transition/transition_with_custom_machine_attribute_test.rb
state_machines-0.1.3 test/unit/transition/transition_with_custom_machine_attribute_test.rb
state_machines-0.1.2 test/unit/transition/transition_with_custom_machine_attribute_test.rb
state_machines-0.1.1 test/unit/transition/transition_with_custom_machine_attribute_test.rb
state_machines-0.1.0 test/unit/transition/transition_with_custom_machine_attribute_test.rb