get all unit tests running again. Seems we have some pretty old code in there :-)

This commit is contained in:
Reinier Balt 2012-04-17 16:47:37 +02:00
parent e964769553
commit fd4fb6df9e
19 changed files with 255 additions and 284 deletions

View file

@ -1,8 +1,9 @@
class MessageGateway < ActionMailer::Base
include ActionView::Helpers::SanitizeHelper
extend ActionView::Helpers::SanitizeHelper::ClassMethods
# include ActionView::Helpers::SanitizeHelper
# extend ActionView::Helpers::SanitizeHelper::ClassMethods
def receive(email)
puts "email = #{email}"
address = ''
if SITE_CONFIG['email_dispatch'] == 'to'
address = email.to[0]
@ -10,9 +11,9 @@ class MessageGateway < ActionMailer::Base
address = email.from[0]
end
user = User.find(:first, :include => [:preference], :conditions => ["preferences.sms_email = ?", address.strip])
user = User.where("preferences.sms_email" => address.strip).first(:include => [:preference])
if user.nil?
user = User.find(:first, :include => [:preference], :conditions => ["preferences.sms_email = ?", address.strip[1,100]])
user = User.where("preferences.sms_email" => address.strip[1.100]).first(:include => [:preference])
end
return if user.nil?
context = user.prefs.sms_context
@ -25,7 +26,7 @@ class MessageGateway < ActionMailer::Base
body_part = email.parts.find{|m| m.content_type == "text/plain"}
notes = sanitize body_part.body.strip
else
if email.subject.empty?
if email.subject && email.subject.blank?
description = sanitize email.body.strip
notes = nil
else
@ -35,7 +36,7 @@ class MessageGateway < ActionMailer::Base
end
# stupid T-Mobile often sends the same message multiple times
return if user.todos.find(:first, :conditions => {:description => description})
return if user.todos.where(:description => description).first
todo = Todo.from_rich_message(user, context.id, description, notes)
todo.save!