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

Merge branch 'master' of git@github.com:rubyist/aasm

This commit is contained in:
Scott Barron 2008-12-12 10:05:22 -05:00
commit 173fa5723b
3 changed files with 22 additions and 7 deletions

View file

@ -22,7 +22,7 @@ module AASM
module ClassMethods module ClassMethods
def inherited(klass) def inherited(klass)
AASM::StateMachine[klass] = AASM::StateMachine[self].dup AASM::StateMachine[klass] = AASM::StateMachine[self].clone
super super
end end

View file

@ -22,6 +22,12 @@ module AASM
@config = OpenStruct.new @config = OpenStruct.new
end end
def clone
klone = super
klone.states = states.clone
klone
end
def create_state(name, options) def create_state(name, options)
@states << AASM::SupportingClasses::State.new(name, options) unless @states.include?(name) @states << AASM::SupportingClasses::State.new(name, options) unless @states.include?(name)
end end

View file

@ -70,12 +70,21 @@ describe AASM, '- class level definitions' do
end end
describe AASM, '- when included' do describe AASM, '- subclassing' do
it 'should invoke the original inherited callback when subclassed' do before(:each) do
parent = Class.new @parent = Class.new do
parent.should_receive(:inherited) include AASM
parent.send(:include, AASM) end
child = Class.new(parent) end
it 'should invoke the original inherited callback' do
@parent.should_receive(:inherited)
Class.new(@parent)
end
it 'should have a unique states hash' do
child = Class.new(@parent)
child.aasm_states.equal?(@parent.aasm_states).should be_false
end end
end end