Sha256: 342f6abaf4d62b363255137a34ea492b7f0d890b37c1145e061d601af1da7631

Contents?: true

Size: 881 Bytes

Versions: 13

Compression:

Stored size: 881 Bytes

Contents

require File.join(File.dirname(__FILE__), 'test_helper')
require 'workflow'

class BeforeTransitionTest < Test::Unit::TestCase
  class MyFlow
    attr_reader :history
    def initialize
      @history = []
    end

    include Workflow
    workflow do
      state :first do
        event :forward, :transitions_to => :second do
          @history << 'forward'
        end
      end
      state :second do
        event :back, :transitions_to => :first do
          @history << 'back'
        end
      end

      before_transition { @history << 'before' }
      after_transition { @history << 'after' }
      on_transition { @history << 'on' }
    end
  end

  test 'that before_transition is run before the action' do
    flow = MyFlow.new
    flow.forward!
    flow.back!
    assert flow.history == ['before', 'forward', 'on', 'after', 'before', 'back', 'on', 'after']
  end
end

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
workflow-orchestrator-1.3.1 test/before_transition_test.rb
workflow-orchestrator-1.3.0 test/before_transition_test.rb
workflow-1.2.0 test/before_transition_test.rb
workflow-1.1.0 test/before_transition_test.rb
workflow-rails4-1.1.0 test/before_transition_test.rb
workflow-1.0.0 test/before_transition_test.rb
workflow-0.8.7 test/before_transition_test.rb
workflow-0.8.6 test/before_transition_test.rb
workflow-0.8.4 test/before_transition_test.rb
workflow-0.8.3 test/before_transition_test.rb
workflow-0.8.1 test/before_transition_test.rb
railsware-workflow-0.8.1 test/before_transition_test.rb
workflow-0.8.0 test/before_transition_test.rb