From 290aded7f6c0321150e36d4456244f3c94e3b37a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Sun, 28 Dec 2014 20:47:10 +0100 Subject: [PATCH] ActionMailer deliver -> deliver_now --- app/mailers/report_mailer.rb | 2 +- app/workers/mail/also_commented.rb | 2 +- app/workers/mail/comment_on_post.rb | 2 +- app/workers/mail/confirm_email.rb | 2 +- app/workers/mail/liked.rb | 2 +- app/workers/mail/mentioned.rb | 2 +- app/workers/mail/private_message.rb | 2 +- app/workers/mail/reshared.rb | 2 +- app/workers/mail/started_sharing.rb | 2 +- app/workers/queue_users_for_removal.rb | 2 +- lib/email_inviter.rb | 2 +- spec/mailers/maintenance_spec.rb | 10 +++++----- spec/mailers/notifier_spec.rb | 2 +- spec/workers/mail/mentioned_spec.rb | 2 +- spec/workers/mail/private_message_spec.rb | 2 +- spec/workers/mail/reshared_spec.rb | 2 +- 16 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/mailers/report_mailer.rb b/app/mailers/report_mailer.rb index 57359cc68..5256add0e 100644 --- a/app/mailers/report_mailer.rb +++ b/app/mailers/report_mailer.rb @@ -13,7 +13,7 @@ class ReportMailer < ActionMailer::Base user = User.find_by_id(person.owner_id) unless user.user_preferences.exists?(:email_type => :someone_reported) resource[:email] = user.email - format(resource).deliver + format(resource).deliver_now end end end diff --git a/app/workers/mail/also_commented.rb b/app/workers/mail/also_commented.rb index 617c1961a..2197c8e25 100644 --- a/app/workers/mail/also_commented.rb +++ b/app/workers/mail/also_commented.rb @@ -5,7 +5,7 @@ module Workers def perform(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 diff --git a/app/workers/mail/comment_on_post.rb b/app/workers/mail/comment_on_post.rb index 5ec07782a..fc397518d 100644 --- a/app/workers/mail/comment_on_post.rb +++ b/app/workers/mail/comment_on_post.rb @@ -4,7 +4,7 @@ module Workers sidekiq_options queue: :mail 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 diff --git a/app/workers/mail/confirm_email.rb b/app/workers/mail/confirm_email.rb index ec7c6742e..05a9cef5e 100644 --- a/app/workers/mail/confirm_email.rb +++ b/app/workers/mail/confirm_email.rb @@ -4,7 +4,7 @@ module Workers sidekiq_options queue: :mail def perform(user_id) - Notifier.confirm_email(user_id).deliver + Notifier.confirm_email(user_id).deliver_now end end end diff --git a/app/workers/mail/liked.rb b/app/workers/mail/liked.rb index 195c73622..a80555859 100644 --- a/app/workers/mail/liked.rb +++ b/app/workers/mail/liked.rb @@ -4,7 +4,7 @@ module Workers sidekiq_options queue: :mail 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 diff --git a/app/workers/mail/mentioned.rb b/app/workers/mail/mentioned.rb index 950063ec6..06dac676b 100644 --- a/app/workers/mail/mentioned.rb +++ b/app/workers/mail/mentioned.rb @@ -9,7 +9,7 @@ module Workers sidekiq_options queue: :mail 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 diff --git a/app/workers/mail/private_message.rb b/app/workers/mail/private_message.rb index 3fe953539..6d48d5dbf 100644 --- a/app/workers/mail/private_message.rb +++ b/app/workers/mail/private_message.rb @@ -9,7 +9,7 @@ module Workers sidekiq_options queue: :mail 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 diff --git a/app/workers/mail/reshared.rb b/app/workers/mail/reshared.rb index 97d74bb61..20df36ac0 100644 --- a/app/workers/mail/reshared.rb +++ b/app/workers/mail/reshared.rb @@ -4,7 +4,7 @@ module Workers sidekiq_options queue: :mail 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 diff --git a/app/workers/mail/started_sharing.rb b/app/workers/mail/started_sharing.rb index 6ca50f96a..3bc4938c8 100644 --- a/app/workers/mail/started_sharing.rb +++ b/app/workers/mail/started_sharing.rb @@ -9,7 +9,7 @@ module Workers sidekiq_options queue: :mail 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 diff --git a/app/workers/queue_users_for_removal.rb b/app/workers/queue_users_for_removal.rb index 63efa3365..6d98837d6 100644 --- a/app/workers/queue_users_for_removal.rb +++ b/app/workers/queue_users_for_removal.rb @@ -31,7 +31,7 @@ module Workers user.flag_for_removal(remove_at) if user.sign_in_count > 0 # send a warning - Maintenance.account_removal_warning(user).deliver + Maintenance.account_removal_warning(user).deliver_now end Workers::RemoveOldUser.perform_in(remove_at+1.day, user.id) end diff --git a/lib/email_inviter.rb b/lib/email_inviter.rb index eaba72310..7f8c54475 100644 --- a/lib/email_inviter.rb +++ b/lib/email_inviter.rb @@ -26,6 +26,6 @@ class EmailInviter private def mail(email) - Notifier.invite(email, message, inviter, invitation_code, locale).deliver! + Notifier.invite(email, message, inviter, invitation_code, locale).deliver_now! end end diff --git a/spec/mailers/maintenance_spec.rb b/spec/mailers/maintenance_spec.rb index d333e5db1..a0df04683 100644 --- a/spec/mailers/maintenance_spec.rb +++ b/spec/mailers/maintenance_spec.rb @@ -13,28 +13,28 @@ describe Maintenance, :type => :mailer do it "#should deliver successfully" do expect { - Maintenance.account_removal_warning(@user).deliver + Maintenance.account_removal_warning(@user).deliver_now }.to_not raise_error end it "#should be added to the delivery queue" do expect { - Maintenance.account_removal_warning(@user).deliver + Maintenance.account_removal_warning(@user).deliver_now }.to change(ActionMailer::Base.deliveries, :size).by(1) end 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) end 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") end 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}") end end diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index 7678ca6f3..ce99f6a15 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -210,7 +210,7 @@ describe Notifier, :type => :mailer do let(:comment) { eve.comment!(commented_post, "Totally is")} 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 expect(comment_mail.to).to eq([bob.email]) diff --git a/spec/workers/mail/mentioned_spec.rb b/spec/workers/mail/mentioned_spec.rb index ac7e787b2..32ab738eb 100644 --- a/spec/workers/mail/mentioned_spec.rb +++ b/spec/workers/mail/mentioned_spec.rb @@ -12,7 +12,7 @@ describe Workers::Mail::Mentioned do m = Mention.new(:person => user.person, :post=> sm) 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) Workers::Mail::Mentioned.new.perform(user.id, sm.author.id, m.id) diff --git a/spec/workers/mail/private_message_spec.rb b/spec/workers/mail/private_message_spec.rb index 9ee1c0fbf..311f7cdce 100644 --- a/spec/workers/mail/private_message_spec.rb +++ b/spec/workers/mail/private_message_spec.rb @@ -18,7 +18,7 @@ describe Workers::Mail::PrivateMessage do message = cnv.messages.first 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) Workers::Mail::Mentioned.new.perform(user2.id, user1.person.id, message.id) diff --git a/spec/workers/mail/reshared_spec.rb b/spec/workers/mail/reshared_spec.rb index 016d75b43..74b5c43ec 100644 --- a/spec/workers/mail/reshared_spec.rb +++ b/spec/workers/mail/reshared_spec.rb @@ -11,7 +11,7 @@ describe Workers::Mail::Reshared do reshare = FactoryGirl.build(:reshare, :author => alice.person, :root=> sm) 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) Workers::Mail::Reshared.new.perform(bob.id, reshare.author.id, reshare.id)