Commit 3af4c864653297ff2796f6d5ddf1836e6906fd9b

Authored by Victor Costa
1 parent 2c762593

Fix email template content type

app/helpers/email_template_helper.rb
1 module EmailTemplateHelper 1 module EmailTemplateHelper
2 2
3 def mail_with_template(params={}) 3 def mail_with_template(params={})
4 - params[:body] = params[:email_template].present? ? params[:email_template].parsed_body(params[:template_params]) : params[:body]  
5 - params[:subject] = params[:email_template].present? ? params[:email_template].parsed_subject(params[:template_params]) : params[:subject] 4 + if params[:email_template].present?
  5 + params[:body] = params[:email_template].parsed_body(params[:template_params])
  6 + params[:subject] = params[:email_template].parsed_subject(params[:template_params])
  7 + params[:content_type] = "text/html"
  8 + end
6 mail(params.except(:email_template)) 9 mail(params.except(:email_template))
7 end 10 end
8 11
test/unit/email_template_helper_test.rb
@@ -7,7 +7,7 @@ class EmailTemplateHelperTest < ActionView::TestCase @@ -7,7 +7,7 @@ class EmailTemplateHelperTest < ActionView::TestCase
7 template.expects(:parsed_body).returns('parsed body') 7 template.expects(:parsed_body).returns('parsed body')
8 template.expects(:parsed_subject).returns('parsed subject') 8 template.expects(:parsed_subject).returns('parsed subject')
9 params = {:subject => 'subject', :body => 'body', :email_template => template} 9 params = {:subject => 'subject', :body => 'body', :email_template => template}
10 - expects(:mail).with({:subject => 'parsed subject', :body => 'parsed body'}) 10 + expects(:mail).with({:subject => 'parsed subject', :body => 'parsed body', :content_type => 'text/html'})
11 mail_with_template(params) 11 mail_with_template(params)
12 end 12 end
13 13