mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-28 21:08:48 +01:00
Fixes #679. Clears completed_at when changing completed todo to active todo. Also creates test for use case in #679
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@760 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
7fa0fc28fc
commit
1ae19fe4fb
2 changed files with 12 additions and 1 deletions
|
|
@ -8,7 +8,9 @@ class Todo < ActiveRecord::Base
|
|||
|
||||
acts_as_state_machine :initial => :active, :column => 'state'
|
||||
|
||||
state :active, :enter => Proc.new { |t| t[:show_from] = nil }
|
||||
# when entering active state, also remove completed_at date.
|
||||
# Looks like :exit of state completed is not run, see #679
|
||||
state :active, :enter => Proc.new { |t| t[:show_from], t.completed_at = nil, nil }
|
||||
state :project_hidden
|
||||
state :completed, :enter => Proc.new { |t| t.completed_at = Time.now.utc }, :exit => Proc.new { |t| t.completed_at = nil }
|
||||
state :deferred
|
||||
|
|
|
|||
|
|
@ -31,6 +31,15 @@ class TodoTest < Test::Rails::TestCase
|
|||
assert_not_nil @completed.completed_at
|
||||
end
|
||||
|
||||
def test_completed_at_cleared_after_toggle_to_active
|
||||
assert_kind_of Todo, @completed
|
||||
assert @completed.completed?
|
||||
@completed.toggle_completion!
|
||||
assert @completed.active?
|
||||
assert_nil @completed.completed_at
|
||||
end
|
||||
|
||||
|
||||
# Validation tests
|
||||
#
|
||||
def test_validate_presence_of_description
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue