Remove old message parameter from invite mail

closes #7571
This commit is contained in:
Benjamin Neff 2017-08-23 02:03:08 +02:00 committed by Steffen van Bergerem
parent b530ed0be0
commit 494518def1
No known key found for this signature in database
GPG key ID: 315C9787D548DC6B
4 changed files with 7 additions and 17 deletions

View file

@ -37,10 +37,8 @@ class Notifier < ApplicationMailer
end
end
def invite(email, message, inviter, invitation_code, locale)
def invite(email, inviter, invitation_code, locale)
@inviter = inviter
@message = message
@locale = locale
@invitation_code = invitation_code
I18n.with_locale(locale) do

View file

@ -1,9 +1,8 @@
class EmailInviter
attr_accessor :emails, :message, :inviter, :locale
attr_accessor :emails, :inviter, :locale
def initialize(emails, inviter, options={})
options = options.symbolize_keys
self.message = options[:message]
self.locale = options.fetch(:locale, 'en')
self.inviter = inviter
self.emails = emails
@ -26,6 +25,6 @@ class EmailInviter
private
def mail(email)
Notifier.invite(email, message, inviter, invitation_code, locale).deliver_now
Notifier.invite(email, inviter, invitation_code, locale).deliver_now
end
end

View file

@ -1,11 +1,10 @@
describe EmailInviter do
before do
@user = double(:invitation_code => 'coolcodebro', :present? => true,
:email => 'foo@bar.com')
@user = double(invitation_code: "coolcodebro", present?: true, email: "foo@bar.com")
@emails = "mbs333@gmail.com, foo1@bar.com maxwell@dude.com"
end
it 'has a list of emails' do
it "has a list of emails" do
inviter = EmailInviter.new(@emails, @user)
expect(inviter.emails).not_to be_empty
end
@ -20,12 +19,6 @@ describe EmailInviter do
expect(inviter.inviter).not_to be_nil
end
it 'can have a message' do
message = "you guys suck hard"
inviter = EmailInviter.new("emails", @user, :message => message)
expect(inviter.message).to eq(message)
end
describe '#emails' do
it 'rejects the inviter email if present' do
inviter = EmailInviter.new(@emails + " #{@user.email}", @user)

View file

@ -502,7 +502,7 @@ describe Notifier, type: :mailer do
end
describe ".invite" do
let(:email) { Notifier.invite(alice.email, nil, bob, "1234", "en") }
let(:email) { Notifier.invite(alice.email, bob, "1234", "en") }
it "goes to the right person" do
expect(email.to).to eq([alice.email])
@ -522,7 +522,7 @@ describe Notifier, type: :mailer do
it "has the inviter id if the name is nil" do
bob.person.profile.update_attributes(first_name: "", last_name: "")
mail = Notifier.invite(alice.email, nil, bob, "1234", "en")
mail = Notifier.invite(alice.email, bob, "1234", "en")
expect(email.body.encoded).to_not include("#{bob.name} (#{bob.diaspora_handle})")
expect(mail.body.encoded).to include(bob.person.diaspora_handle)
end