diff --git a/app/models/contact.rb b/app/models/contact.rb index 902ff96..459b7a8 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -23,9 +23,11 @@ class Contact < ActiveRecord::Base #WithoutTable class Sender < ActionMailer::Base def mail(contact) + content_type 'text/html' emails = contact.dest.notification_emails recipients emails - from "#{contact.name} <#{contact.email}>" + from "#{contact.name} <#{contact.dest.environment.contact_email}>" + reply_to contact.email if contact.sender headers 'X-Noosfero-Sender' => contact.sender.identifier end diff --git a/app/views/contact/sender/mail.rhtml b/app/views/contact/sender/mail.rhtml index 49a11b2..91917ce 100644 --- a/app/views/contact/sender/mail.rhtml +++ b/app/views/contact/sender/mail.rhtml @@ -1,21 +1,27 @@ -<%= _('This message was sent by %{sender} to %{target} on %{environment}.') % - {:sender => @name, :target => @target, :environment => @environment} %> -<%= _('Below here are the informations about the user who sent this message:')%> - + + + + + + +

<%= _('This message was sent by %{sender} to %{target} on %{environment}.') % + {:sender => @name, :target => @target, :environment => @environment} %>

+ <%= _('Information about the user who sent this message:')%> + +
+ <%= content_tag('b', _('Message:')) %> +

<%= word_wrap(@message) %>

-<%= _('Message:') %> -------------------------------------------------------------------------------- -<%= word_wrap(@message) %> -------------------------------------------------------------------------------- + --
+ <%= _('Greetings,') %>
+ <%= _('%s team.') % @environment %>
+ <%= @url %> + + -<%= _('Greetings,') %> - --- -<%= _('%s team.') % @environment %> -<%= @url %> diff --git a/test/unit/contact_test.rb b/test/unit/contact_test.rb index bc71fc2..e9c16dc 100644 --- a/test/unit/contact_test.rb +++ b/test/unit/contact_test.rb @@ -22,7 +22,7 @@ class ContactTest < ActiveSupport::TestCase should 'validates format of email only if not empty' do contact = Contact.new contact.valid? - assert_match /^.* can't be blank$/, contact.errors[:email] + assert_match(/^.* can't be blank$/, contact.errors[:email]) end should 'inicialize fields on instanciate' do @@ -44,4 +44,25 @@ class ContactTest < ActiveSupport::TestCase assert !c.deliver end + should 'use sender name and environment contact_email on from' do + ent = fast_create(Enterprise, :name => 'my enterprise', :identifier => 'myent') + c = Contact.new(:name => 'john', :email => 'john@invalid.com', :subject => 'hi', :message => 'hi, all', :dest => ent) + email = c.deliver + assert_equal "#{c.name} <#{ent.environment.contact_email}>", email['from'].to_s + end + + should 'add dest name on subject' do + ent = fast_create(Enterprise, :name => 'my enterprise', :identifier => 'myent') + c = Contact.new(:name => 'john', :email => 'john@invalid.com', :subject => 'hi', :message => 'hi, all', :dest => ent) + email = c.deliver + assert_equal "[#{ent.short_name(30)}] #{c.subject}", email['subject'].to_s + end + + should 'add sender email on reply_to' do + ent = fast_create(Enterprise, :name => 'my enterprise', :identifier => 'myent') + c = Contact.new(:name => 'john', :email => 'john@invalid.com', :subject => 'hi', :message => 'hi, all', :dest => ent) + email = c.deliver + assert_equal c.email, email.reply_to.to_s + end + end -- libgit2 0.21.2