Extend RichMessage format to include other data

Uses new Regex to detect:

 @ context
 ~ project
 > tickler-date
 < due-date
 # tag (repeatable)
 * (starred)
This commit is contained in:
Greg Sutcliffe 2013-10-13 22:11:55 +01:00
parent 1441d53808
commit 2f043911c6
7 changed files with 180 additions and 25 deletions

View file

@ -18,4 +18,23 @@ class TodoFromRichMessageTest < ActiveSupport::TestCase
assert_equal default_context_id, new_todo.context_id
end
def test_from_rich_message_adds_all_fields
user = @completed.user
context = Context.create(:name => 'context')
project = Project.create(:name => 'project')
message = "description@context~project>131014<131017#tag1#tag2*"
builder = TodoFromRichMessage.new(user, context.id, message, "notes")
new_todo = builder.construct
assert_not_nil new_todo
assert_equal "description", new_todo.description
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 "starred, tag1, tag2", new_todo.tags.to_s
assert new_todo.starred?
end
end