Sha256: 570c9dba2acf649b31b96e2fb9d5a00b0e0fe6cb568c327050a8d9f9c99a5096

Contents?: true

Size: 1.03 KB

Versions: 16

Compression:

Stored size: 1.03 KB

Contents

require_relative 'test_helper'

class MachineWithFailedBeforeCallbacksTest < BaseTestCase
  def setup
    @callbacks = []

    @model = new_model
    @machine = StateMachines::Machine.new(@model)
    @machine.state :parked, :idling
    @machine.event :ignite
    @machine.before_transition { @callbacks << :before_1; false }
    @machine.before_transition { @callbacks << :before_2 }
    @machine.after_transition { @callbacks << :after }
    @machine.around_transition { |block| @callbacks << :around_before; block.call; @callbacks << :around_after }

    @record = @model.new(:state => 'parked')
    @transition = StateMachines::Transition.new(@record, @machine, :ignite, :parked, :idling)
    @result = @transition.perform
  end

  def test_should_not_be_successful
    refute @result
  end

  def test_should_not_change_current_state
    assert_equal 'parked', @record.state
  end

  def test_should_not_run_action
    assert @record.new_record?
  end

  def test_should_not_run_further_callbacks
    assert_equal [:before_1], @callbacks
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

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