Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Found and fixed issue where completed_at date is nil for tasks
  • Loading branch information
rwilcox committed Nov 16, 2010
1 parent ae57dbe commit 9eb745d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/stonepath/task.rb
Expand Up @@ -15,7 +15,15 @@ def self.default_config_block
lambda {
aasm_initial_state :active
aasm_state :active, :after_enter => :notify_created
aasm_state :completed, :after_enter => [:timestamp_complete, :notify_closed]
aasm_state :completed, :enter => :timestamp_complete, :after_enter => :notify_closed
# was:
#aasm_state :completed, :after_enter => [:timestamp_complete, :notify_closed]
# but, from investigations into AASM,
# persist is done after :enter but before :after_exit, etc
# so fields changed in :after_enter will result in a dirty object that
# never gets saved to the DB
# WD-rpw / Ashish Tonse 11-16-2010

aasm_state :expired, :after_enter => :notify_closed
aasm_state :cancelled, :after_enter => :notify_closed

Expand Down
10 changes: 9 additions & 1 deletion test/task_test.rb
Expand Up @@ -25,7 +25,15 @@ def setup
a.complete!
assert_equal("completed", a.aasm_state)
end


should "see a completed_at date when an assignment is completed" do
c = Case.create
a = c.assignments.create
a.complete!
a = a.reload
assert_not_nil(a.completed_at)
end

should "be able to cancel an assignment" do
c = Case.create
a = c.assignments.create
Expand Down

0 comments on commit 9eb745d

Please sign in to comment.