mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-26 03:58:49 +01:00
fix #1305 and #1309. Only check on show_from in the past when you change the show_from. This will not prevent a save of the todo when another change is made and show_from has some old date
This commit is contained in:
parent
be26cfdd66
commit
dd83040ea0
3 changed files with 32 additions and 12 deletions
|
|
@ -67,9 +67,9 @@ class TodoTest < ActiveSupport::TestCase
|
|||
|
||||
def test_validate_show_from_must_be_a_date_in_the_future
|
||||
t = @not_completed2
|
||||
t[:show_from] = 1.week.ago # we have to set this via the indexer because show_from=() updates the state
|
||||
# and actual show_from value appropriately based on the date
|
||||
assert !t.save
|
||||
t.show_from = 1.week.ago
|
||||
|
||||
assert !t.save, "todo should not be saved without validation errors"
|
||||
assert_equal 1, t.errors.count
|
||||
assert_equal "must be a date in the future", t.errors[:show_from][0]
|
||||
end
|
||||
|
|
@ -128,6 +128,24 @@ class TodoTest < ActiveSupport::TestCase
|
|||
t.toggle_completion!
|
||||
assert_equal :active, t.aasm_current_state
|
||||
end
|
||||
|
||||
def test_toggle_completion_with_show_from_in_future
|
||||
t = @not_completed1
|
||||
t.show_from= 1.week.from_now
|
||||
t.save!
|
||||
assert_equal :deferred, t.aasm_current_state
|
||||
t.toggle_completion!
|
||||
assert_equal :completed, t.aasm_current_state
|
||||
end
|
||||
|
||||
def test_toggle_completion_with_show_from_in_past
|
||||
t = @not_completed1
|
||||
t.update_attribute(:show_from, 1.week.ago)
|
||||
assert_equal :active, t.aasm_current_state
|
||||
|
||||
assert t.toggle_completion!, "shoud be able to mark active todo complete even if show_from is set in the past"
|
||||
assert_equal :completed, t.aasm_current_state
|
||||
end
|
||||
|
||||
def test_activate_also_saves
|
||||
t = @not_completed1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue