Sha256: 10ec9e1e6519978db16ecc41415f4d6033201858a4caefb7162624fdd497b02f
Contents?: true
Size: 1.11 KB
Versions: 5
Compression:
Stored size: 1.11 KB
Contents
require 'active_record' require 'active_record/edge-state-machine' ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:") class Order < ActiveRecord::Base include ActiveRecord::EdgeStateMachine state_machine do state :opened state :placed state :paid state :prepared state :delivered state :cancelled # no timestamp col is being specified here - should be ignored event :place do transition :from => :opened, :to => :placed end # should set paid_at timestamp event :pay do transition :from => :placed, :to => :paid end # should set prepared_on event :prepare do transition :from => :paid, :to => :prepared end # should set dispatched_at event :deliver do transition :from => :prepared, :to => :delivered end # should set cancellation_date event :cancel do transition :from => [:placed, :paid, :prepared], :to => :cancelled end # should raise an exception as there is no timestamp col event :reopen do transition :from => :cancelled, :to => :opened end end end
Version data entries
5 entries across 5 versions & 1 rubygems