FIX: Don't try to send invite email when invite was deleted
This commit is contained in:
parent
bf9b7f1f25
commit
b2cf725700
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue