Loading app/mailers/notifier.rb +1 −3 Original line number Diff line number Diff line Loading @@ -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 Loading lib/email_inviter.rb +2 −3 Original line number Diff line number Diff line 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 Loading @@ -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 spec/lib/email_inviter_spec.rb +2 −9 Original line number Diff line number Diff line 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 Loading @@ -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) Loading spec/mailers/notifier_spec.rb +2 −2 Original line number Diff line number Diff line Loading @@ -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]) Loading @@ -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 Loading Loading
app/mailers/notifier.rb +1 −3 Original line number Diff line number Diff line Loading @@ -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 Loading
lib/email_inviter.rb +2 −3 Original line number Diff line number Diff line 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 Loading @@ -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
spec/lib/email_inviter_spec.rb +2 −9 Original line number Diff line number Diff line 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 Loading @@ -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) Loading
spec/mailers/notifier_spec.rb +2 −2 Original line number Diff line number Diff line Loading @@ -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]) Loading @@ -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 Loading