-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test for inheritance, to check issue aasm#64
- Loading branch information
Ernesto Tagwerker
committed
Apr 30, 2013
1 parent
7f98b99
commit 7e9d869
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Son < Father | ||
include AASM | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |