summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/hcl/day_entry.rb4
-rw-r--r--test/day_entry_test.rb13
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/hcl/day_entry.rb b/lib/hcl/day_entry.rb
index bfc6dbf..3405108 100644
--- a/lib/hcl/day_entry.rb
+++ b/lib/hcl/day_entry.rb
@@ -23,6 +23,10 @@ module HCl
end
end
+ def notes
+ super || @data[:notes] = ''
+ end
+
# Append a string to the notes for this task.
def append_note new_notes
# If I don't include hours it gets reset.
diff --git a/test/day_entry_test.rb b/test/day_entry_test.rb
index 5c9b37d..c27ffda 100644
--- a/test/day_entry_test.rb
+++ b/test/day_entry_test.rb
@@ -33,4 +33,17 @@ class DayEntryTest < Test::Unit::TestCase
end
end
+ should "append to an existing note" do
+ entry = HCl::DayEntry.new(:id => '1', :notes => 'yourmom.', :hours => '1.0')
+ HCl::DayEntry.stubs(:post)
+ entry.append_note('hi world')
+ assert_equal 'yourmom. hi world', entry.notes
+ end
+
+ should "append to an undefined note" do
+ entry = HCl::DayEntry.new(:id => '1', :notes => nil, :hours => '1.0')
+ HCl::DayEntry.stubs(:post)
+ entry.append_note('hi world')
+ assert_equal ' hi world', entry.notes
+ end
end