diff options
-rw-r--r-- | app/models/contact_mailer.rb | 2 | ||||
-rw-r--r-- | spec/models/contact_mailer_spec.rb | 16 |
2 files changed, 16 insertions, 2 deletions
diff --git a/app/models/contact_mailer.rb b/app/models/contact_mailer.rb index abde64928..318f54ea8 100644 --- a/app/models/contact_mailer.rb +++ b/app/models/contact_mailer.rb @@ -8,7 +8,7 @@ class ContactMailer < ApplicationMailer # Send message to administrator def to_admin_message(name, email, subject, message, logged_in_user, last_request, last_body) - @from = name + " <" + email + ">" + @from = "#{name} <#{email}>" @recipients = contact_from_name_and_email @subject = subject @body = { :message => message, diff --git a/spec/models/contact_mailer_spec.rb b/spec/models/contact_mailer_spec.rb index 202e45758..3af55ad77 100644 --- a/spec/models/contact_mailer_spec.rb +++ b/spec/models/contact_mailer_spec.rb @@ -1,8 +1,22 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') -describe ContactMailer, " when blah" do +describe ContactMailer, "when sending mail with a SafeBuffer name param (as when a suspended user + sends a message)" do before do + + end + + it 'should set a "from" address correctly' do + mail = ContactMailer.create_to_admin_message('test (account suspended)'.html_safe, + 'test@example.com', + 'Test subject', + 'Test message', + mock_model(User, :url_name => 'test_user'), + mock_model(InfoRequest, :url_title => 'test_request'), + mock_model(PublicBody, :url_name => 'test_public_body')) + mail.from.should_not be_nil end + end |