mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-06 09:18:50 +01:00
Didn't handle case of no user found gracefully
This commit is contained in:
parent
8783beb280
commit
920507441d
2 changed files with 10 additions and 0 deletions
|
|
@ -2,6 +2,8 @@ class SMSGateway < ActionMailer::Base
|
|||
CONTEXT_NAME = 'Inbox'
|
||||
def receive(email)
|
||||
user = User.find(:first, :include => [:preference], :conditions => ["preferences.sms_email = ?", email.from[0].strip])
|
||||
logger.info "Receiving SMS task from #{email.from[0].strip} For user #{user.nil? nil : user.login}"
|
||||
return if user.nil?
|
||||
context = user.prefs.sms_context
|
||||
|
||||
description = nil
|
||||
|
|
|
|||
|
|
@ -48,4 +48,12 @@ class SMSGatewayTest < Test::Rails::TestCase
|
|||
assert_equal(@user, message_todo.user)
|
||||
assert_equal("This is the message body", message_todo.notes)
|
||||
end
|
||||
|
||||
def test_no_user
|
||||
todo_count = Todo.count
|
||||
badmessage = File.read(File.join(RAILS_ROOT, 'test', 'fixtures', 'sample_sms.txt'))
|
||||
badmessage.gsub!("5555555555", "notauser")
|
||||
SMSGateway.receive(badmessage)
|
||||
assert_equal(todo_count, Todo.count)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue