Created
June 5, 2009 03:44
-
-
Save dnch/124034 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 Report | |
| # ENGINEERING MACHINATIONS | |
| machine(:status, :field_name => "status") do | |
| # we are waiting for someone to upload a file | |
| state :file_pending do | |
| event :upload_file, :to => :file_uploaded | |
| end | |
| # we've got a file, but it's not approved by a hu-man | |
| state :file_uploaded do | |
| # requires :uploaded_file | |
| event :approve_file, :to => :file_approved | |
| event :reject_file, :to => :file_rejected | |
| end | |
| # the file is shit and needs to be re-uploaded | |
| state :file_rejected do | |
| # on_entry :deliver_rejection_notification | |
| # requires :rejection_reason | |
| event :upload_file, :to => :file_uploaded | |
| end | |
| # we like the file. let's start the extraction. | |
| state :file_approved do | |
| # on_entry :deliver_approval_notification | |
| event :process, :to => :being_processed | |
| 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
| it "should follow our stateful path quite nicely" do | |
| @report = Report.make | |
| @report.status.name.should eql(:file_pending) | |
| @report.upload_file! | |
| @report.status.name.should eql(:file_uploaded) | |
| @report.reject_file! | |
| @report.status.name.should eql(:file_rejected) | |
| @report.upload_file! | |
| @report.status.name.should eql(:file_uploaded) | |
| @report.approve_file! | |
| @report.status.name.should eql(:file_approved) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment