mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-22 23:24:07 +01:00
Added SMS and MMS gateway that can handle a variety of messages formats along with a set of testes for it.
NOTE: this is the first patch submitted on ticket
This commit is contained in:
parent
1d64ca0f34
commit
8783beb280
13 changed files with 525 additions and 2 deletions
51
test/unit/sms_gateway_test.rb
Normal file
51
test/unit/sms_gateway_test.rb
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class SMSGatewayTest < Test::Rails::TestCase
|
||||
fixtures :users, :contexts
|
||||
|
||||
def setup
|
||||
@user = users(:sms_user)
|
||||
@inbox = contexts(:inbox)
|
||||
end
|
||||
|
||||
def load_message(filename)
|
||||
SMSGateway.receive(File.read(File.join(RAILS_ROOT, 'test', 'fixtures', filename)))
|
||||
end
|
||||
|
||||
def test_sms_with_no_subject
|
||||
todo_count = Todo.count
|
||||
|
||||
load_message('sample_sms.txt')
|
||||
# assert some stuff about it being created
|
||||
assert_equal(todo_count+1, Todo.count)
|
||||
|
||||
message_todo = Todo.find(:first, :conditions => {:description => "This is a todo 4112093"})
|
||||
assert_not_nil(message_todo)
|
||||
|
||||
assert_equal(@inbox, message_todo.context)
|
||||
assert_equal(@user, message_todo.user)
|
||||
end
|
||||
|
||||
def test_double_sms
|
||||
todo_count = Todo.count
|
||||
load_message('sample_sms.txt')
|
||||
load_message('sample_sms.txt')
|
||||
assert_equal(todo_count+1, Todo.count)
|
||||
end
|
||||
|
||||
def test_mms_with_subject
|
||||
todo_count = Todo.count
|
||||
|
||||
load_message('sample_mms.txt')
|
||||
|
||||
# assert some stuff about it being created
|
||||
assert_equal(todo_count+1, Todo.count)
|
||||
|
||||
message_todo = Todo.find(:first, :conditions => {:description => "This is the subject"})
|
||||
assert_not_nil(message_todo)
|
||||
|
||||
assert_equal(@inbox, message_todo.context)
|
||||
assert_equal(@user, message_todo.user)
|
||||
assert_equal("This is the message body", message_todo.notes)
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue