Skip to content

Commit

Permalink
fix various tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ttilley committed Aug 27, 2010
1 parent 84f6293 commit d853e9c
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 21 deletions.
12 changes: 6 additions & 6 deletions lib/aasm/persistence/active_record_persistence.rb
Expand Up @@ -38,14 +38,14 @@ def self.included(base)
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
Expand Down Expand Up @@ -236,8 +236,8 @@ def aasm_read_state
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
Expand Down
4 changes: 2 additions & 2 deletions spec/functional/conversation_spec.rb
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
@@ -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'

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/aasm_spec.rb
@@ -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
Expand Down
10 changes: 4 additions & 6 deletions spec/unit/active_record_persistence_spec.rb
@@ -1,5 +1,3 @@
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'aasm')

begin
require 'rubygems'
require 'active_record'
Expand Down Expand Up @@ -214,15 +212,15 @@ class NamedScopeExample < ActiveRecord::Base
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
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/before_after_callbacks_spec.rb
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/event_spec.rb
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/state_spec.rb
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/state_transition_spec.rb
@@ -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
Expand Down

0 comments on commit d853e9c

Please sign in to comment.