FIX: Don't try to send invite email when invite was deleted

This commit is contained in:
Gerhard Schlager 2018-08-29 12:02:47 +02:00
parent bf9b7f1f25
commit b2cf725700
2 changed files with 7 additions and 0 deletions

View File

@ -9,6 +9,8 @@ module Jobs
raise 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).send
end

View File

@ -20,6 +20,11 @@ describe Jobs::InviteEmail do
Jobs::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)
end
end
end