mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
Added test for inheritance, to check issue #64
This commit is contained in:
parent
7f98b99f7d
commit
7e9d86902d
3 changed files with 42 additions and 0 deletions
21
spec/models/father.rb
Normal file
21
spec/models/father.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
require 'active_record'
|
||||
|
||||
class Father < ActiveRecord::Base
|
||||
include AASM
|
||||
|
||||
aasm do
|
||||
state :missing_details, :initial => true
|
||||
state :pending_details_confirmation
|
||||
|
||||
event :add_details do
|
||||
transitions :from => :missing_details, :to => :pending_details_confirmation
|
||||
end
|
||||
end
|
||||
|
||||
def update_state
|
||||
if may_add_details?
|
||||
add_details!
|
||||
end
|
||||
end
|
||||
|
||||
end
|
3
spec/models/son.rb
Normal file
3
spec/models/son.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
class Son < Father
|
||||
include AASM
|
||||
end
|
18
spec/unit/inheritance_spec.rb
Normal file
18
spec/unit/inheritance_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'inheritance behavior' do
|
||||
let(:son) {Son.new}
|
||||
|
||||
it 'should be in the pending state' do
|
||||
son.aasm_current_state.should == :missing_details
|
||||
end
|
||||
|
||||
it 'should know how to respond to `may_add_details?`' do
|
||||
son.may_add_details?.should be_true
|
||||
end
|
||||
|
||||
it 'should not break if I call Son#update_state' do
|
||||
son.update_state
|
||||
son.aasm_current_state.should == :pending_details_confirmation
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue