A platform for community discussion. Free, open, simple.
FIX: Don't try to send invite email when invite was deleted
Gerhard Schlagerb2cf72570025
diff --git a/app/jobs/regular/invite_email.rb b/app/jobs/regular/invite_email.rbindex f373134a2bd..09c2dd0dba8 100644--- a/app/jobs/regular/invite_email.rb+++ b/app/jobs/regular/invite_email.rb@@ -9,6 +9,8 @@ module Jobsraise Discourse::InvalidParameters.new(:invite_id) unless args[:invite_id].present?invite = Invite.find_by(id: args[:invite_id])+ return unless invite.present?+message = InviteMailer.send_invite(invite)Email::Sender.new(message, :invite).sendenddiff --git a/spec/jobs/invite_email_spec.rb b/spec/jobs/invite_email_spec.rbindex 184fd60b468..9d31a761da2 100644--- a/spec/jobs/invite_email_spec.rb+++ b/spec/jobs/invite_email_spec.rb@@ -20,6 +20,11 @@ describe Jobs::InviteEmail doJobs::InviteEmail.new.execute(invite_id: invite.id)end+ it "aborts without error when the invite doesn't exist anymore" do+ invite.destroy+ InviteMailer.expects(:send_invite).never+ Jobs::InviteEmail.new.execute(invite_id: invite.id)+ endendend