ActionMailer deliver -> deliver_now

This commit is contained in:
Jonne Haß 2014-12-28 20:47:10 +01:00
parent 162303db37
commit 290aded7f6
16 changed files with 20 additions and 20 deletions

View file

@ -13,7 +13,7 @@ class ReportMailer < ActionMailer::Base
user = User.find_by_id(person.owner_id) user = User.find_by_id(person.owner_id)
unless user.user_preferences.exists?(:email_type => :someone_reported) unless user.user_preferences.exists?(:email_type => :someone_reported)
resource[:email] = user.email resource[:email] = user.email
format(resource).deliver format(resource).deliver_now
end end
end end
end end

View file

@ -5,7 +5,7 @@ module Workers
def perform(recipient_id, sender_id, comment_id) def perform(recipient_id, sender_id, comment_id)
if email = Notifier.also_commented(recipient_id, sender_id, comment_id) if email = Notifier.also_commented(recipient_id, sender_id, comment_id)
email.deliver email.deliver_now
end end
end end
end end

View file

@ -4,7 +4,7 @@ module Workers
sidekiq_options queue: :mail sidekiq_options queue: :mail
def perform(recipient_id, sender_id, comment_id) def perform(recipient_id, sender_id, comment_id)
Notifier.comment_on_post(recipient_id, sender_id, comment_id).deliver Notifier.comment_on_post(recipient_id, sender_id, comment_id).deliver_now
end end
end end
end end

View file

@ -4,7 +4,7 @@ module Workers
sidekiq_options queue: :mail sidekiq_options queue: :mail
def perform(user_id) def perform(user_id)
Notifier.confirm_email(user_id).deliver Notifier.confirm_email(user_id).deliver_now
end end
end end
end end

View file

@ -4,7 +4,7 @@ module Workers
sidekiq_options queue: :mail sidekiq_options queue: :mail
def perform(recipient_id, sender_id, like_id) def perform(recipient_id, sender_id, like_id)
Notifier.liked(recipient_id, sender_id, like_id).deliver Notifier.liked(recipient_id, sender_id, like_id).deliver_now
end end
end end
end end

View file

@ -9,7 +9,7 @@ module Workers
sidekiq_options queue: :mail sidekiq_options queue: :mail
def perform(recipient_id, actor_id, target_id) def perform(recipient_id, actor_id, target_id)
Notifier.mentioned( recipient_id, actor_id, target_id).deliver Notifier.mentioned( recipient_id, actor_id, target_id).deliver_now
end end
end end
end end

View file

@ -9,7 +9,7 @@ module Workers
sidekiq_options queue: :mail sidekiq_options queue: :mail
def perform(recipient_id, actor_id, target_id) def perform(recipient_id, actor_id, target_id)
Notifier.private_message( recipient_id, actor_id, target_id).deliver Notifier.private_message( recipient_id, actor_id, target_id).deliver_now
end end
end end
end end

View file

@ -4,7 +4,7 @@ module Workers
sidekiq_options queue: :mail sidekiq_options queue: :mail
def perform(recipient_id, sender_id, reshare_id) def perform(recipient_id, sender_id, reshare_id)
Notifier.reshared(recipient_id, sender_id, reshare_id).deliver Notifier.reshared(recipient_id, sender_id, reshare_id).deliver_now
end end
end end
end end

View file

@ -9,7 +9,7 @@ module Workers
sidekiq_options queue: :mail sidekiq_options queue: :mail
def perform(recipient_id, sender_id, target_id) def perform(recipient_id, sender_id, target_id)
Notifier.started_sharing(recipient_id, sender_id).deliver Notifier.started_sharing(recipient_id, sender_id).deliver_now
end end
end end
end end

View file

@ -31,7 +31,7 @@ module Workers
user.flag_for_removal(remove_at) user.flag_for_removal(remove_at)
if user.sign_in_count > 0 if user.sign_in_count > 0
# send a warning # send a warning
Maintenance.account_removal_warning(user).deliver Maintenance.account_removal_warning(user).deliver_now
end end
Workers::RemoveOldUser.perform_in(remove_at+1.day, user.id) Workers::RemoveOldUser.perform_in(remove_at+1.day, user.id)
end end

View file

@ -26,6 +26,6 @@ class EmailInviter
private private
def mail(email) def mail(email)
Notifier.invite(email, message, inviter, invitation_code, locale).deliver! Notifier.invite(email, message, inviter, invitation_code, locale).deliver_now!
end end
end end

View file

@ -13,28 +13,28 @@ describe Maintenance, :type => :mailer do
it "#should deliver successfully" do it "#should deliver successfully" do
expect { expect {
Maintenance.account_removal_warning(@user).deliver Maintenance.account_removal_warning(@user).deliver_now
}.to_not raise_error }.to_not raise_error
end end
it "#should be added to the delivery queue" do it "#should be added to the delivery queue" do
expect { expect {
Maintenance.account_removal_warning(@user).deliver Maintenance.account_removal_warning(@user).deliver_now
}.to change(ActionMailer::Base.deliveries, :size).by(1) }.to change(ActionMailer::Base.deliveries, :size).by(1)
end end
it "#should include correct recipient" do it "#should include correct recipient" do
Maintenance.account_removal_warning(@user).deliver Maintenance.account_removal_warning(@user).deliver_now
expect(ActionMailer::Base.deliveries.last.to[0]).to include(@user.email) expect(ActionMailer::Base.deliveries.last.to[0]).to include(@user.email)
end end
it "#should include after inactivity days from settings" do it "#should include after inactivity days from settings" do
Maintenance.account_removal_warning(@user).deliver Maintenance.account_removal_warning(@user).deliver_now
expect(ActionMailer::Base.deliveries.last.body.parts[0].body.raw_source).to include("for #{AppConfig.settings.maintenance.remove_old_users.after_days} days") expect(ActionMailer::Base.deliveries.last.body.parts[0].body.raw_source).to include("for #{AppConfig.settings.maintenance.remove_old_users.after_days} days")
end end
it "#should include timestamp for account removal" do it "#should include timestamp for account removal" do
Maintenance.account_removal_warning(@user).deliver Maintenance.account_removal_warning(@user).deliver_now
expect(ActionMailer::Base.deliveries.last.body.parts[0].body.raw_source).to include("sign in to your account before #{@removal_timestamp.utc}") expect(ActionMailer::Base.deliveries.last.body.parts[0].body.raw_source).to include("sign in to your account before #{@removal_timestamp.utc}")
end end
end end

View file

@ -210,7 +210,7 @@ describe Notifier, :type => :mailer do
let(:comment) { eve.comment!(commented_post, "Totally is")} let(:comment) { eve.comment!(commented_post, "Totally is")}
describe ".comment_on_post" do describe ".comment_on_post" do
let(:comment_mail) {Notifier.comment_on_post(bob.id, person.id, comment.id).deliver} let(:comment_mail) {Notifier.comment_on_post(bob.id, person.id, comment.id).deliver_now}
it 'TO: goes to the right person' do it 'TO: goes to the right person' do
expect(comment_mail.to).to eq([bob.email]) expect(comment_mail.to).to eq([bob.email])

View file

@ -12,7 +12,7 @@ describe Workers::Mail::Mentioned do
m = Mention.new(:person => user.person, :post=> sm) m = Mention.new(:person => user.person, :post=> sm)
mail_double = double() mail_double = double()
expect(mail_double).to receive(:deliver) expect(mail_double).to receive(:deliver_now)
expect(Notifier).to receive(:mentioned).with(user.id, sm.author.id, m.id).and_return(mail_double) expect(Notifier).to receive(:mentioned).with(user.id, sm.author.id, m.id).and_return(mail_double)
Workers::Mail::Mentioned.new.perform(user.id, sm.author.id, m.id) Workers::Mail::Mentioned.new.perform(user.id, sm.author.id, m.id)

View file

@ -18,7 +18,7 @@ describe Workers::Mail::PrivateMessage do
message = cnv.messages.first message = cnv.messages.first
mail_double = double() mail_double = double()
expect(mail_double).to receive(:deliver) expect(mail_double).to receive(:deliver_now)
expect(Notifier).to receive(:mentioned).with(user2.id, user1.person.id, message.id).and_return(mail_double) expect(Notifier).to receive(:mentioned).with(user2.id, user1.person.id, message.id).and_return(mail_double)
Workers::Mail::Mentioned.new.perform(user2.id, user1.person.id, message.id) Workers::Mail::Mentioned.new.perform(user2.id, user1.person.id, message.id)

View file

@ -11,7 +11,7 @@ describe Workers::Mail::Reshared do
reshare = FactoryGirl.build(:reshare, :author => alice.person, :root=> sm) reshare = FactoryGirl.build(:reshare, :author => alice.person, :root=> sm)
mail_double = double() mail_double = double()
expect(mail_double).to receive(:deliver) expect(mail_double).to receive(:deliver_now)
expect(Notifier).to receive(:reshared).with(bob.id, reshare.author.id, reshare.id).and_return(mail_double) expect(Notifier).to receive(:reshared).with(bob.id, reshare.author.id, reshare.id).and_return(mail_double)
Workers::Mail::Reshared.new.perform(bob.id, reshare.author.id, reshare.id) Workers::Mail::Reshared.new.perform(bob.id, reshare.author.id, reshare.id)