Sha256: 709122cbbed15b374b694cca923f1c387d02ad44efcb61556dafde140c9a356b

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

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

$VERBOSE = false
require 'active_record'
require 'sqlite3'
require 'workflow'

ActiveRecord::Migration.verbose = false

class Article < ActiveRecord::Base
  include Workflow

  workflow do
    state :new
    state :accepted
  end
end

class ActiveRecordScopesTest < ActiveRecordTestCase

  def setup
    super

    ActiveRecord::Schema.define do
      create_table :articles do |t|
        t.string :title
        t.string :body
        t.string :blame_reason
        t.string :reject_reason
        t.string :workflow_state
      end
    end
  end

  def assert_state(title, expected_state, klass = Order)
    o = klass.find_by_title(title)
    assert_equal expected_state, o.read_attribute(klass.workflow_column)
    o
  end

  test 'have "with_new_state" scope' do
    assert_respond_to Article, :with_new_state
  end

  test 'have "with_accepted_state" scope' do
    assert_respond_to Article, :with_accepted_state
  end

  test 'have "without_new_state" scope' do
    assert_respond_to Article, :without_new_state
  end

  test 'have "without_accepted_state" scope' do
    assert_respond_to Article, :without_accepted_state
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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