fix various tests

This commit is contained in:
Travis Tilley 2010-08-27 16:35:26 -04:00
parent 84f62932b9
commit d853e9cb26
9 changed files with 19 additions and 21 deletions

View File

@ -38,14 +38,14 @@ module AASM
base.send(:include, AASM::Persistence::ActiveRecordPersistence::WriteState) unless base.method_defined?(:aasm_write_state)
base.send(:include, AASM::Persistence::ActiveRecordPersistence::WriteStateWithoutPersistence) unless base.method_defined?(:aasm_write_state_without_persistence)
if base.respond_to?(:named_scope)
if base.respond_to?(:scope)
base.extend(AASM::Persistence::ActiveRecordPersistence::NamedScopeMethods)
base.class_eval do
class << self
unless method_defined?(:aasm_state_without_named_scope)
alias_method :aasm_state_without_named_scope, :aasm_state
alias_method :aasm_state, :aasm_state_with_named_scope
unless method_defined?(:aasm_state_without_scope)
alias_method :aasm_state_without_scope, :aasm_state
alias_method :aasm_state, :aasm_state_with_scope
end
end
end
@ -236,8 +236,8 @@ module AASM
end
module NamedScopeMethods
def aasm_state_with_named_scope name, options = {}
aasm_state_without_named_scope name, options
def aasm_state_with_scope name, options = {}
aasm_state_without_scope name, options
self.scope name, :conditions => { "#{table_name}.#{self.aasm_column}" => name.to_s} unless self.respond_to?(name)
end
end

View File

@ -1,5 +1,5 @@
require File.join(File.dirname(__FILE__), "..", "spec_helper")
require File.join(File.dirname(__FILE__), 'conversation')
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
require File.expand_path(File.join(File.dirname(__FILE__), 'conversation'))
describe Conversation, 'description' do
it '.aasm_states should contain all of the states' do

View File

@ -1,5 +1,5 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
require 'aasm'

View File

@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
class Foo
include AASM

View File

@ -1,5 +1,3 @@
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'aasm')
begin
require 'rubygems'
require 'active_record'
@ -214,15 +212,15 @@ begin
end
context "Does not already respond_to? the scope name" do
it "should add a named_scope" do
NamedScopeExample.should_receive(:named_scope)
it "should add a scope" do
NamedScopeExample.should_receive(:scope)
NamedScopeExample.aasm_state :unknown_scope
end
end
context "Already respond_to? the scope name" do
it "should not add a named_scope" do
NamedScopeExample.should_not_receive(:named_scope)
it "should not add a scope" do
NamedScopeExample.should_not_receive(:scope)
NamedScopeExample.aasm_state :new
end
end

View File

@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
class Foo2
include AASM

View File

@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
describe AASM::SupportingClasses::Event do
before(:each) do

View File

@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
# TODO These are specs ported from original aasm
describe AASM::SupportingClasses::State do

View File

@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
describe AASM::SupportingClasses::StateTransition do
it 'should set from, to, and opts attr readers' do