mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-24 03:00:12 +01:00
Use Rich Todo API for Message Gateway
This commit is contained in:
parent
3353626016
commit
6e4258cfbc
2 changed files with 5 additions and 92 deletions
|
|
@ -60,8 +60,8 @@ class MessageGatewayTest < Test::Rails::TestCase
|
|||
def test_direct_to_context
|
||||
message = File.read(File.join(RAILS_ROOT, 'test', 'fixtures', 'sample_sms.txt'))
|
||||
|
||||
valid_context_msg = message.gsub('message_content', 'anothercontext: this is a task')
|
||||
invalid_context_msg = message.gsub('message_content', 'notacontext: this is a task')
|
||||
valid_context_msg = message.gsub('message_content', 'this is a task @ anothercontext')
|
||||
invalid_context_msg = message.gsub('message_content', 'this is also a task @ notacontext')
|
||||
|
||||
MessageGateway.receive(valid_context_msg)
|
||||
valid_context_todo = Todo.find(:first, :conditions => {:description => "this is a task"})
|
||||
|
|
@ -69,67 +69,8 @@ class MessageGatewayTest < Test::Rails::TestCase
|
|||
assert_equal(contexts(:anothercontext), valid_context_todo.context)
|
||||
|
||||
MessageGateway.receive(invalid_context_msg)
|
||||
invalid_context_todo = Todo.find(:first, :conditions => {:description => 'notacontext: this is a task'})
|
||||
invalid_context_todo = Todo.find(:first, :conditions => {:description => 'this is also a task'})
|
||||
assert_not_nil(invalid_context_todo)
|
||||
assert_equal(@inbox, invalid_context_todo.context)
|
||||
end
|
||||
|
||||
def test_due_date
|
||||
message = File.read(File.join(RAILS_ROOT, 'test', 'fixtures', 'sample_sms.txt'))
|
||||
|
||||
valid_due_msg1 = message.gsub('message_content', 'do something tomorrow due:6/15/2008')
|
||||
valid_due_msg2 = message.gsub('message_content', 'do something tomorrow due:6/28/2008 and remember it!')
|
||||
valid_due_msg3 = message.gsub('message_content', 'due:1/28/2008 funky!')
|
||||
invalid_due_msg1 = message.gsub('message_content', 'do something tomorrow due:xxxx and remember it!')
|
||||
|
||||
MessageGateway.receive(valid_due_msg1)
|
||||
valid_due_todo1 = Todo.find(:first, :conditions => {:description => "do something tomorrow"})
|
||||
assert_not_nil(valid_due_todo1)
|
||||
assert_equal(Date.civil(2008, 6, 15), valid_due_todo1.due)
|
||||
|
||||
MessageGateway.receive(valid_due_msg2)
|
||||
valid_due_todo2 = Todo.find(:first, :conditions => {:description => "do something tomorrow and remember it!"})
|
||||
assert_not_nil(valid_due_todo2)
|
||||
assert_equal(Date.civil(2008, 6, 28), valid_due_todo2.due)
|
||||
|
||||
MessageGateway.receive(valid_due_msg3)
|
||||
valid_due_todo3 = Todo.find(:first, :conditions => {:description => "funky!"})
|
||||
assert_not_nil(valid_due_todo3)
|
||||
assert_equal(Date.civil(2008, 1, 28), valid_due_todo3.due)
|
||||
|
||||
MessageGateway.receive(invalid_due_msg1)
|
||||
invalid_due_todo1 = Todo.find(:first, :conditions => {:description => "do something tomorrow due:xxxx and remember it!"})
|
||||
assert_not_nil(invalid_due_todo1)
|
||||
assert_nil(invalid_due_todo1.due)
|
||||
end
|
||||
|
||||
def test_show_date
|
||||
message = File.read(File.join(RAILS_ROOT, 'test', 'fixtures', 'sample_sms.txt'))
|
||||
|
||||
valid_show_msg1 = message.gsub('message_content', "do something tomorrow show:#{Date.tomorrow.to_s}")
|
||||
valid_show_msg2 = message.gsub('message_content', "do something next week show:#{Date.today.next_week.to_s} and remember it!")
|
||||
valid_show_msg3 = message.gsub('message_content', "show:#{Date.tomorrow.to_s} alternative format")
|
||||
invalid_show_msg1 = message.gsub('message_content', 'do something tomorrow show:xxxx and remember it!')
|
||||
|
||||
MessageGateway.receive(valid_show_msg1)
|
||||
valid_show_todo1 = Todo.find(:first, :conditions => {:description => "do something tomorrow"})
|
||||
assert_not_nil(valid_show_todo1)
|
||||
assert_equal(Date.tomorrow, valid_show_todo1.show_from)
|
||||
|
||||
MessageGateway.receive(valid_show_msg2)
|
||||
valid_show_todo2 = Todo.find(:first, :conditions => {:description => "do something next week and remember it!"})
|
||||
assert_not_nil(valid_show_todo2)
|
||||
assert_equal(Date.today.next_week, valid_show_todo2.show_from)
|
||||
|
||||
MessageGateway.receive(valid_show_msg3)
|
||||
valid_show_todo3 = Todo.find(:first, :conditions => {:description => "alternative format"})
|
||||
# p @user.todos.last
|
||||
assert_not_nil(valid_show_todo3)
|
||||
assert_equal(Date.tomorrow, valid_show_todo3.show_from)
|
||||
|
||||
MessageGateway.receive(invalid_show_msg1)
|
||||
invalid_show_todo1 = Todo.find(:first, :conditions => {:description => "do something tomorrow show:xxxx and remember it!"})
|
||||
assert_not_nil(invalid_show_todo1)
|
||||
assert_nil(invalid_show_todo1.show_from)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue