Created
January 27, 2009 14:51
-
-
Save siannopollo/53370 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class Request < ActiveRecord::Base | |
| state_machine :state, :initial => :pending_owner_approval do | |
| event :approve do | |
| transition :from => :pending_owner_approval, :to => :pending_shipping_confirmation | |
| end | |
| event :deny do | |
| transition :from => :pending_owner_approval, :to => :denied | |
| end | |
| event :shipping_confirmed do | |
| transition :from => :pending_shipping_confirmation, :to => :in_transit | |
| end | |
| event :received do | |
| transition :from => :in_transit, :to => :complete | |
| end | |
| end | |
| end |
This file contains hidden or 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
| ... | |
| describe 'lifecycle' do | |
| it 'should start out as pending owner approval' do | |
| @model.should be_pending_owner_approval | |
| end | |
| it 'should be approved' do | |
| @model.approve | |
| @model.should be_pending_shipping_confirmation | |
| end | |
| it 'should be denied' do | |
| @model.deny | |
| @model.should be_denied | |
| end | |
| it 'should allow shipping to be confirmed' do | |
| @model.approve | |
| @model.shipping_confirmed | |
| @model.should be_in_transit | |
| end | |
| it 'should allow receipt of the item' do | |
| @model.approve | |
| @model.shipping_confirmed | |
| @model.received | |
| @model.should be_complete | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment