summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/hcl/commands.rb3
-rw-r--r--test/command_test.rb8
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/hcl/commands.rb b/lib/hcl/commands.rb
index c753fbf..9bad615 100644
--- a/lib/hcl/commands.rb
+++ b/lib/hcl/commands.rb
@@ -45,6 +45,9 @@ module HCl
def cancel
entry = DayEntry.with_timer(http) || DayEntry.last(http)
if entry
+ confirmed = /^y/.match(ask("#{entry}\nDelete this entry? (y/n): ").downcase)
+ return unless confirmed
+
if entry.cancel http
"Deleted entry #{entry}."
else
diff --git a/test/command_test.rb b/test/command_test.rb
index 2e2812f..e3f9806 100644
--- a/test/command_test.rb
+++ b/test/command_test.rb
@@ -100,6 +100,14 @@ class CommandTest < HCl::TestCase
entry = stub
HCl::DayEntry.expects(:with_timer).with(http).returns(entry)
entry.expects(:cancel).with(http).returns(true)
+ expects(:ask).returns('y')
+ cancel
+ end
+
+ def test_cancel_no
+ entry = stub
+ HCl::DayEntry.expects(:with_timer).with(http).returns(entry)
+ expects(:ask).returns('n')
cancel
end