mirror of
https://github.com/TracksApp/tracks.git
synced 2025-09-21 21:40:48 +02:00
make todo_from_rich_message time zone aware. test was failing.
This commit is contained in:
parent
76b0ec024a
commit
63af3bbcfa
3 changed files with 10 additions and 6 deletions
|
@ -51,12 +51,12 @@ class RichMessageExtractor
|
|||
|
||||
def due
|
||||
due = select_for DUE_MARKER
|
||||
due.blank? ? nil : Date.parse(due[1].strip)
|
||||
due.blank? ? nil : Time.zone.parse(fix_date_string(due[1].strip))
|
||||
end
|
||||
|
||||
def show_from
|
||||
show_from = select_for TICKLER_MARKER
|
||||
show_from.blank? ? nil : Date.parse(show_from[1].strip)
|
||||
show_from.blank? ? nil : Time.zone.parse(fix_date_string(show_from[1].strip))
|
||||
end
|
||||
|
||||
def starred?
|
||||
|
@ -69,4 +69,8 @@ class RichMessageExtractor
|
|||
@message.match /#{symbol}(.*?)(?=[#{ALL_MARKERS.join}]|\Z)/
|
||||
end
|
||||
|
||||
def fix_date_string yymmdd
|
||||
"20#{yymmdd[0..1]}-#{yymmdd[2..3]}-#{yymmdd[4..5]} 00:00"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -48,8 +48,8 @@ class TodoFromRichMessage
|
|||
todo.raw_notes = notes
|
||||
todo.context_id = context_id
|
||||
todo.project_id = project_id unless project_id.nil?
|
||||
todo.show_from = show_from if show_from.is_a? Date
|
||||
todo.due = due if due.is_a? Date
|
||||
todo.show_from = show_from if show_from.is_a? Time
|
||||
todo.due = due if due.is_a? Time
|
||||
todo.tag_with tags unless tags.nil? || tags.empty?
|
||||
todo.starred = star
|
||||
todo
|
||||
|
|
|
@ -31,8 +31,8 @@ class TodoFromRichMessageTest < ActiveSupport::TestCase
|
|||
assert_equal "notes", new_todo.notes
|
||||
assert_equal context.id, new_todo.context_id
|
||||
assert_equal project.id, new_todo.project_id
|
||||
assert_equal "2013-10-14 00:00:00 +0100", new_todo.show_from.to_s
|
||||
assert_equal "2013-10-17 00:00:00 +0100", new_todo.due.to_s
|
||||
assert_equal Time.zone.parse("2013-10-14 00:00"). utc.to_s, new_todo.show_from.utc.to_s
|
||||
assert_equal Time.zone.parse("2013-10-17 00:00"), new_todo.due.utc.to_s
|
||||
assert_equal "starred, tag1, tag2", new_todo.tags.to_s
|
||||
assert new_todo.starred?
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue