Sha256: 21847b68725689eb003904c09dd329dcef111cc5190c2a7ba99358fdea81c776

Contents?: true

Size: 988 Bytes

Versions: 3

Compression:

Stored size: 988 Bytes

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
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
workflow-1.2.0 test/active_record_scopes_test.rb
workflow-1.1.0 test/active_record_scopes_test.rb
workflow-rails4-1.1.0 test/active_record_scopes_test.rb