Sha256: 708064c74e60aa30d5e1d86feab2c6581381f30c399744a751f2c99a08c91526

Contents?: true

Size: 734 Bytes

Versions: 2

Compression:

Stored size: 734 Bytes

Contents

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

class EnumValuesTest < ActiveRecordTestCase
  test 'that the value of the state is persisted instead of the name' do
  
    ActiveRecord::Schema.define do
      create_table(:active_enum_flows) { |t| t.integer :state }
    end

    class ActiveEnumFlow < ActiveRecord::Base
      include Workflow
      workflow_column :state

      workflow do
        state :first, 1 do
          event :forward, :transitions_to => :second
        end
        state :second, 2 do
          event :back, :transitions_to => :first
        end
      end
    end

    flow = ActiveEnumFlow.create
    flow.forward!
    assert flow.state == 2
    assert flow.second?
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workflow-orchestrator-1.3.1 test/enum_values_test.rb
workflow-orchestrator-1.3.0 test/enum_values_test.rb