Replace Diaspora* with pod_name in the FROM header
Add pod name to FROM: header for no sender case
This commit is contained in:
parent
2be0644281
commit
ce90d6a020
4 changed files with 20 additions and 17 deletions
|
|
@ -34,13 +34,13 @@ module NotificationMailers
|
||||||
|
|
||||||
def default_headers
|
def default_headers
|
||||||
headers = {
|
headers = {
|
||||||
from: AppConfig.mail.sender_address.get,
|
from: "\"#{AppConfig.settings.pod_name}\" <#{AppConfig.mail.sender_address}>",
|
||||||
host: "#{AppConfig.pod_uri.host}",
|
host: "#{AppConfig.pod_uri.host}",
|
||||||
to: name_and_address(@recipient.name, @recipient.email)
|
to: name_and_address(@recipient.name, @recipient.email)
|
||||||
}
|
}
|
||||||
return headers if @sender.blank?
|
return headers if @sender.blank?
|
||||||
sender_in_header = @sender.profile.full_name.empty? ? @sender.username : @sender.name
|
sender_in_header = @sender.profile.full_name.empty? ? @sender.username : @sender.name
|
||||||
headers[:from] = "\"Diaspora* (#{sender_in_header})\" <#{AppConfig.mail.sender_address}>"
|
headers[:from] = "\"#{AppConfig.settings.pod_name} (#{sender_in_header})\" <#{AppConfig.mail.sender_address}>"
|
||||||
|
|
||||||
headers
|
headers
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class ReportMailer < ActionMailer::Base
|
class ReportMailer < ActionMailer::Base
|
||||||
default from: AppConfig.mail.sender_address
|
default from: "\"#{AppConfig.settings.pod_name}\" <#{AppConfig.mail.sender_address}>"
|
||||||
|
|
||||||
def self.new_report(report_id)
|
def self.new_report(report_id)
|
||||||
report = Report.find_by_id(report_id)
|
report = Report.find_by_id(report_id)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
describe Notifier, type: :mailer do
|
describe Notifier, type: :mailer do
|
||||||
let(:person) { FactoryGirl.create(:person) }
|
let(:person) { FactoryGirl.create(:person) }
|
||||||
|
let(:pod_name) { AppConfig.settings.pod_name }
|
||||||
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Notifier.deliveries = []
|
Notifier.deliveries = []
|
||||||
|
|
@ -246,7 +248,7 @@ describe Notifier, type: :mailer do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "FROM: contains the sender's name" do
|
it "FROM: contains the sender's name" do
|
||||||
expect(@mail["From"].to_s).to eq("\"Diaspora* (#{@cnv.author.name})\" <#{AppConfig.mail.sender_address}>")
|
expect(@mail["From"].to_s).to eq("\"#{pod_name} (#{@cnv.author.name})\" <#{AppConfig.mail.sender_address}>")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should use a generic subject" do
|
it "should use a generic subject" do
|
||||||
|
|
@ -290,7 +292,7 @@ describe Notifier, type: :mailer do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "FROM: contains the sender's name" do
|
it "FROM: contains the sender's name" do
|
||||||
expect(comment_mail["From"].to_s).to eq("\"Diaspora* (#{eve.name})\" <#{AppConfig.mail.sender_address}>")
|
expect(comment_mail["From"].to_s).to eq("\"#{pod_name} (#{eve.name})\" <#{AppConfig.mail.sender_address}>")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "SUBJECT: has a snippet of the post contents, without markdown and without newlines" do
|
it "SUBJECT: has a snippet of the post contents, without markdown and without newlines" do
|
||||||
|
|
@ -331,7 +333,7 @@ describe Notifier, type: :mailer do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "FROM: has the name of person commenting as the sender" do
|
it "FROM: has the name of person commenting as the sender" do
|
||||||
expect(comment_mail["From"].to_s).to eq("\"Diaspora* (#{eve.name})\" <#{AppConfig.mail.sender_address}>")
|
expect(comment_mail["From"].to_s).to eq("\"#{pod_name} (#{eve.name})\" <#{AppConfig.mail.sender_address}>")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "SUBJECT: has a snippet of the post contents, without markdown and without newlines" do
|
it "SUBJECT: has a snippet of the post contents, without markdown and without newlines" do
|
||||||
|
|
@ -386,7 +388,7 @@ describe Notifier, type: :mailer do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "FROM: contains the sender's name" do
|
it "FROM: contains the sender's name" do
|
||||||
expect(mail["From"].to_s).to eq("\"Diaspora* (#{bob.name})\" <#{AppConfig.mail.sender_address}>")
|
expect(mail["From"].to_s).to eq("\"#{pod_name} (#{bob.name})\" <#{AppConfig.mail.sender_address}>")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "SUBJECT: does not show the limited post" do
|
it "SUBJECT: does not show the limited post" do
|
||||||
|
|
@ -411,7 +413,7 @@ describe Notifier, type: :mailer do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "FROM: contains the sender's name" do
|
it "FROM: contains the sender's name" do
|
||||||
expect(mail["From"].to_s).to eq("\"Diaspora* (#{bob.name})\" <#{AppConfig.mail.sender_address}>")
|
expect(mail["From"].to_s).to eq("\"#{pod_name} (#{bob.name})\" <#{AppConfig.mail.sender_address}>")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "SUBJECT: does not show the limited post" do
|
it "SUBJECT: does not show the limited post" do
|
||||||
|
|
@ -442,7 +444,7 @@ describe Notifier, type: :mailer do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "FROM: contains the sender's name" do
|
it "FROM: contains the sender's name" do
|
||||||
expect(mail["From"].to_s).to eq("\"Diaspora* (#{bob.name})\" <#{AppConfig.mail.sender_address}>")
|
expect(mail["From"].to_s).to eq("\"#{pod_name} (#{bob.name})\" <#{AppConfig.mail.sender_address}>")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "SUBJECT: does not show the limited post" do
|
it "SUBJECT: does not show the limited post" do
|
||||||
|
|
@ -478,8 +480,8 @@ describe Notifier, type: :mailer do
|
||||||
expect(@confirm_email.to).to eq([bob.unconfirmed_email])
|
expect(@confirm_email.to).to eq([bob.unconfirmed_email])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "FROM: header should be the default sender address" do
|
it "FROM: header should be the pod name with default sender address" do
|
||||||
expect(@confirm_email["From"].to_s).to eq(AppConfig.mail.sender_address.to_s)
|
expect(@confirm_email["From"].to_s).to eq("#{pod_name} <#{AppConfig.mail.sender_address}>")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "has the unconfirmed email in the subject" do
|
it "has the unconfirmed email in the subject" do
|
||||||
|
|
@ -506,8 +508,8 @@ describe Notifier, type: :mailer do
|
||||||
expect(email.to).to eq([alice.email])
|
expect(email.to).to eq([alice.email])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "FROM: header should be the default sender address" do
|
it "FROM: header should be the pod name + default sender address" do
|
||||||
expect(email["From"].to_s).to eq(AppConfig.mail.sender_address.to_s)
|
expect(email["From"].to_s).to eq("#{pod_name} <#{AppConfig.mail.sender_address}>")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "has the correct subject" do
|
it "has the correct subject" do
|
||||||
|
|
@ -544,10 +546,10 @@ describe Notifier, type: :mailer do
|
||||||
}.to_not raise_error
|
}.to_not raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it "FROM: header should be 'Diaspora* (username)' when there is no first and last name" do
|
it "FROM: header should be 'pod_name (username)' when there is no first and last name" do
|
||||||
bob.person.profile.update_attributes(first_name: "", last_name: "")
|
bob.person.profile.update_attributes(first_name: "", last_name: "")
|
||||||
mail = Notifier.send_notification("started_sharing", alice.id, bob.person.id)
|
mail = Notifier.send_notification("started_sharing", alice.id, bob.person.id)
|
||||||
expect(mail["From"].to_s).to eq("\"Diaspora* (#{bob.person.username})\" <#{AppConfig.mail.sender_address}>")
|
expect(mail["From"].to_s).to eq("\"#{pod_name} (#{bob.person.username})\" <#{AppConfig.mail.sender_address}>")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,10 @@ describe Report, type: :mailer do
|
||||||
expect(ActionMailer::Base.deliveries[1].to[0]).to include(@user2.email)
|
expect(ActionMailer::Base.deliveries[1].to[0]).to include(@user2.email)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "FROM: header should be the default sender address" do
|
it "FROM: header should be the pod name + default sender address" do
|
||||||
ReportMailer.new_report(@post_report.id).each(&:deliver_now)
|
ReportMailer.new_report(@post_report.id).each(&:deliver_now)
|
||||||
expect(ReportMailer.default[:from].to_s).to eq(AppConfig.mail.sender_address.to_s)
|
pod_name = AppConfig.settings.pod_name
|
||||||
|
expect(ReportMailer.default[:from].to_s).to eq("\"#{pod_name}\" <#{AppConfig.mail.sender_address}>")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should send mail in recipent's prefered language" do
|
it "should send mail in recipent's prefered language" do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue