1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00

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

View file

@ -1,5 +1,5 @@
require File.join(File.dirname(__FILE__), "..", "spec_helper") require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
require File.join(File.dirname(__FILE__), 'conversation') require File.expand_path(File.join(File.dirname(__FILE__), 'conversation'))
describe Conversation, 'description' do describe Conversation, 'description' do
it '.aasm_states should contain all of the states' 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.expand_path(File.dirname(__FILE__)))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
require 'aasm' 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 class Foo
include AASM include AASM

View file

@ -1,5 +1,3 @@
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'aasm')
begin begin
require 'rubygems' require 'rubygems'
require 'active_record' require 'active_record'
@ -214,15 +212,15 @@ begin
end end
context "Does not already respond_to? the scope name" do context "Does not already respond_to? the scope name" do
it "should add a named_scope" do it "should add a scope" do
NamedScopeExample.should_receive(:named_scope) NamedScopeExample.should_receive(:scope)
NamedScopeExample.aasm_state :unknown_scope NamedScopeExample.aasm_state :unknown_scope
end end
end end
context "Already respond_to? the scope name" do context "Already respond_to? the scope name" do
it "should not add a named_scope" do it "should not add a scope" do
NamedScopeExample.should_not_receive(:named_scope) NamedScopeExample.should_not_receive(:scope)
NamedScopeExample.aasm_state :new NamedScopeExample.aasm_state :new
end end
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 class Foo2
include AASM 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 describe AASM::SupportingClasses::Event do
before(:each) 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 # TODO These are specs ported from original aasm
describe AASM::SupportingClasses::State do 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 describe AASM::SupportingClasses::StateTransition do
it 'should set from, to, and opts attr readers' do it 'should set from, to, and opts attr readers' do