summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZack Hobson2014-01-27 07:45:06 -0800
committerZack Hobson2014-01-27 07:45:06 -0800
commit36b95d194373c2f76c71a6ffdae5df4f91402340 (patch)
tree55326b7b3ee61e2e1341b4ced1baa4ad4c855715
parente8e3ad0737603c14b8e9c51d863e840b4ea4a931 (diff)
downloadhcl-36b95d194373c2f76c71a6ffdae5df4f91402340.tar.bz2
fix: crash when stopping a timer the next day
-rw-r--r--CHANGELOG.markdown1
-rw-r--r--lib/hcl/commands.rb2
-rw-r--r--test/command_test.rb9
3 files changed, 11 insertions, 1 deletions
diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown
index 3cf6142..f9ebff9 100644
--- a/CHANGELOG.markdown
+++ b/CHANGELOG.markdown
@@ -5,6 +5,7 @@
* added --changelog option
* remove completion command, cache aliases in a file instead, closes #51
* confirm timer deletion/cancellation, closes #47
+* fixed: crash when stopping a timer the next day
## v0.4.11 2014-01-25
diff --git a/lib/hcl/commands.rb b/lib/hcl/commands.rb
index 9bad615..4156a69 100644
--- a/lib/hcl/commands.rb
+++ b/lib/hcl/commands.rb
@@ -111,7 +111,7 @@ module HCl
end
def stop *args
- entry = DayEntry.with_timer(http) || DayEntry.with_timer(http, DateTime.yesterday)
+ entry = DayEntry.with_timer(http) || DayEntry.with_timer(http, Date.today - 1)
if entry
entry.append_note(http, args.join(' ')) if args.any?
entry.toggle http
diff --git a/test/command_test.rb b/test/command_test.rb
index e3f9806..69bad62 100644
--- a/test/command_test.rb
+++ b/test/command_test.rb
@@ -81,6 +81,15 @@ class CommandTest < HCl::TestCase
stop 'all done'
end
+ def test_yesterday
+ entry = stub
+ register_uri(:get, '/daily', {day_entries:[]})
+ register_uri(:get, '/daily/026/2014', {day_entries:[{id:321,notes:'',hours:1,client:nil,project:nil,timer_started_at:DateTime.now}]})
+ register_uri(:post, '/daily/update/321', {day_entry:{notes:'all done next day'}})
+ register_uri(:get, '/daily/timer/321')
+ stop 'all done next day'
+ end
+
def test_resume
entry = stub
HCl::DayEntry.expects(:last).returns(entry)