diff options
| -rw-r--r-- | CHANGELOG.markdown | 1 | ||||
| -rw-r--r-- | lib/hcl/commands.rb | 2 | ||||
| -rw-r--r-- | test/command_test.rb | 9 | 
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) | 
