mirror of
https://github.com/TracksApp/tracks.git
synced 2026-04-18 10:09:02 +02:00
update gems and fix failures from new aasm
I'm not sure the test failures caused by reload not working are caused by the new aasm, perhaps the thread isolation is causing that...
This commit is contained in:
parent
93b0a2557c
commit
5ed69fc1a2
7 changed files with 91 additions and 85 deletions
|
|
@ -14,23 +14,24 @@ class Context < ActiveRecord::Base
|
|||
|
||||
# state machine
|
||||
include AASM
|
||||
aasm_column :state
|
||||
aasm_initial_state :active
|
||||
|
||||
aasm_state :active
|
||||
aasm_state :closed
|
||||
aasm_state :hidden
|
||||
aasm :column => :state do
|
||||
|
||||
state :active, :initial => true
|
||||
state :closed
|
||||
state :hidden
|
||||
|
||||
aasm_event :close do
|
||||
transitions :to => :closed, :from => [:active, :hidden], :guard => :no_active_todos?
|
||||
end
|
||||
event :close do
|
||||
transitions :to => :closed, :from => [:active, :hidden], :guard => :no_active_todos?
|
||||
end
|
||||
|
||||
aasm_event :hide do
|
||||
transitions :to => :hidden, :from => [:active, :closed]
|
||||
end
|
||||
event :hide do
|
||||
transitions :to => :hidden, :from => [:active, :closed]
|
||||
end
|
||||
|
||||
aasm_event :activate do
|
||||
transitions :to => :active, :from => [:closed, :hidden]
|
||||
event :activate do
|
||||
transitions :to => :active, :from => [:closed, :hidden]
|
||||
end
|
||||
end
|
||||
|
||||
attr_protected :user
|
||||
|
|
|
|||
|
|
@ -20,26 +20,24 @@ class Project < ActiveRecord::Base
|
|||
acts_as_list :scope => 'user_id = #{user_id} AND state = \'#{state}\'', :top_of_list => 0
|
||||
|
||||
include AASM
|
||||
aasm_column :state
|
||||
aasm_initial_state :active
|
||||
|
||||
# extend NamePartFinder
|
||||
# include Tracks::TodoList
|
||||
aasm :column => :state do
|
||||
|
||||
aasm_state :active
|
||||
aasm_state :hidden, :enter => :hide_todos, :exit => :unhide_todos
|
||||
aasm_state :completed, :enter => :set_completed_at_date, :exit => :clear_completed_at_date
|
||||
state :active, :initial => true
|
||||
state :hidden, :enter => :hide_todos, :exit => :unhide_todos
|
||||
state :completed, :enter => :set_completed_at_date, :exit => :clear_completed_at_date
|
||||
|
||||
aasm_event :activate do
|
||||
transitions :to => :active, :from => [:active, :hidden, :completed]
|
||||
end
|
||||
event :activate do
|
||||
transitions :to => :active, :from => [:active, :hidden, :completed]
|
||||
end
|
||||
|
||||
aasm_event :hide do
|
||||
transitions :to => :hidden, :from => [:active, :completed]
|
||||
end
|
||||
event :hide do
|
||||
transitions :to => :hidden, :from => [:active, :completed]
|
||||
end
|
||||
|
||||
aasm_event :complete do
|
||||
transitions :to => :completed, :from => [:active, :hidden]
|
||||
event :complete do
|
||||
transitions :to => :completed, :from => [:active, :hidden]
|
||||
end
|
||||
end
|
||||
|
||||
attr_protected :user
|
||||
|
|
|
|||
|
|
@ -13,18 +13,17 @@ class RecurringTodo < ActiveRecord::Base
|
|||
include IsTaggable
|
||||
|
||||
include AASM
|
||||
aasm_column :state
|
||||
aasm_initial_state :active
|
||||
aasm :column => :state do
|
||||
state :active, :initial => true, :before_enter => Proc.new { |t| t.occurences_count = 0 }
|
||||
state :completed, :before_enter => Proc.new { |t| t.completed_at = Time.zone.now }, :before_exit => Proc.new { |t| t.completed_at = nil }
|
||||
|
||||
aasm_state :active, :enter => Proc.new { |t| t.occurences_count = 0 }
|
||||
aasm_state :completed, :enter => Proc.new { |t| t.completed_at = Time.zone.now }, :exit => Proc.new { |t| t.completed_at = nil }
|
||||
event :complete do
|
||||
transitions :to => :completed, :from => [:active]
|
||||
end
|
||||
|
||||
aasm_event :complete do
|
||||
transitions :to => :completed, :from => [:active]
|
||||
end
|
||||
|
||||
aasm_event :activate do
|
||||
transitions :to => :active, :from => [:completed]
|
||||
event :activate do
|
||||
transitions :to => :active, :from => [:completed]
|
||||
end
|
||||
end
|
||||
|
||||
validates_presence_of :description
|
||||
|
|
|
|||
|
|
@ -56,43 +56,45 @@ class Todo < ActiveRecord::Base
|
|||
|
||||
# state machine
|
||||
include AASM
|
||||
aasm_column :state
|
||||
aasm_initial_state Proc.new { |t| (t.show_from && t.user && (t.show_from > t.user.date)) ? :deferred : :active}
|
||||
|
||||
aasm_state :active
|
||||
aasm_state :project_hidden
|
||||
aasm_state :completed, :enter => Proc.new { |t| t.completed_at = Time.zone.now }, :exit => Proc.new { |t| t.completed_at = nil}
|
||||
aasm_state :deferred, :exit => Proc.new { |t| t[:show_from] = nil }
|
||||
aasm_state :pending
|
||||
aasm :column => :state do
|
||||
|
||||
aasm_event :defer do
|
||||
transitions :to => :deferred, :from => [:active]
|
||||
end
|
||||
state :active
|
||||
state :project_hidden
|
||||
state :completed, :enter => Proc.new { |t| t.completed_at = Time.zone.now }, :exit => Proc.new { |t| t.completed_at = nil}
|
||||
state :deferred, :after_exit => Proc.new { |t| t[:show_from] = nil}
|
||||
state :pending
|
||||
|
||||
aasm_event :complete do
|
||||
transitions :to => :completed, :from => [:active, :project_hidden, :deferred, :pending]
|
||||
end
|
||||
event :defer do
|
||||
transitions :to => :deferred, :from => [:active]
|
||||
end
|
||||
|
||||
aasm_event :activate do
|
||||
transitions :to => :active, :from => [:project_hidden, :deferred]
|
||||
transitions :to => :active, :from => [:completed], :guard => :no_uncompleted_predecessors?
|
||||
transitions :to => :active, :from => [:pending], :guard => :no_uncompleted_predecessors_or_deferral?
|
||||
transitions :to => :pending, :from => [:completed], :guard => :uncompleted_predecessors?
|
||||
transitions :to => :deferred, :from => [:pending], :guard => :no_uncompleted_predecessors?
|
||||
end
|
||||
event :complete do
|
||||
transitions :to => :completed, :from => [:active, :project_hidden, :deferred, :pending]
|
||||
end
|
||||
|
||||
aasm_event :hide do
|
||||
transitions :to => :project_hidden, :from => [:active, :deferred, :pending]
|
||||
end
|
||||
event :activate do
|
||||
transitions :to => :active, :from => [:project_hidden, :deferred]
|
||||
transitions :to => :active, :from => [:completed], :guard => :no_uncompleted_predecessors?
|
||||
transitions :to => :active, :from => [:pending], :guard => :no_uncompleted_predecessors_or_deferral?
|
||||
transitions :to => :pending, :from => [:completed], :guard => :uncompleted_predecessors?
|
||||
transitions :to => :deferred, :from => [:pending], :guard => :no_uncompleted_predecessors?
|
||||
end
|
||||
|
||||
aasm_event :unhide do
|
||||
transitions :to => :deferred, :from => [:project_hidden], :guard => Proc.new{|t| !t.show_from.blank? }
|
||||
transitions :to => :pending, :from => [:project_hidden], :guard => :uncompleted_predecessors?
|
||||
transitions :to => :active, :from => [:project_hidden]
|
||||
end
|
||||
event :hide do
|
||||
transitions :to => :project_hidden, :from => [:active, :deferred, :pending]
|
||||
end
|
||||
|
||||
aasm_event :block do
|
||||
transitions :to => :pending, :from => [:active, :deferred]
|
||||
event :unhide do
|
||||
transitions :to => :deferred, :from => [:project_hidden], :guard => Proc.new{|t| !t.show_from.blank? }
|
||||
transitions :to => :pending, :from => [:project_hidden], :guard => :uncompleted_predecessors?
|
||||
transitions :to => :active, :from => [:project_hidden]
|
||||
end
|
||||
|
||||
event :block do
|
||||
transitions :to => :pending, :from => [:active, :deferred]
|
||||
end
|
||||
end
|
||||
|
||||
attr_protected :user
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue