Sha256: e0ba999e2dd720eeb42fdbb6786d81a38417104967549364fa3be0d303ae6a07

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

test_dir = File.dirname(__FILE__)
$:.unshift test_dir unless $:.include?(test_dir)

require 'test_helper'

require 'workflow'

class WithoutWorkflowTest < Test::Unit::TestCase
  class Article
    include Workflow
    workflow do
      state :new do
        event :submit, :transitions_to => :awaiting_review
      end
      state :awaiting_review do
        event :review, :transitions_to => :being_reviewed
      end
      state :being_reviewed do
        event :accept, :transitions_to => :accepted
        event :reject, :transitions_to => :rejected
      end
      state :accepted
      state :rejected
    end
  end

  def test_readme_example_article
    article = Article.new
    assert article.new?
  end

  test 'better error message on transitions_to typo' do
    assert_raise Workflow::WorkflowDefinitionError do
      Class.new do
        include Workflow
        workflow do
          state :new do
            event :event1, :transitionnn => :next # missing transitions_to target
          end
          state :next
        end
      end
    end
  end

  test 'check transition_to alias' do
    Class.new do
      include Workflow
      workflow do
        state :new do
          event :event1, :transition_to => :next
        end
        state :next
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workflow_on_mongoid-1.0.0.0 test/without_active_record_test.rb
workflow_on_mongoid-0.8.0.7 test/without_active_record_test.rb