FIX: reminder job is not erroring when a post is deleted (#98)

We should not error in reminder job when a post is already deleted.

In that case, we should simply skip and don't send any notifications.
This commit is contained in:
Krzysztof Kotlarek 2021-01-25 18:52:35 +11:00 committed by GitHub
parent 802d56977a
commit 708916b31a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -9,6 +9,9 @@ module Jobs
raise Discourse::InvalidParameters.new(:reminder) if args[:reminder].blank?
event = DiscoursePostEvent::Event.includes(post: [:topic], invitees: [:user]).find(args[:event_id])
return unless event.post
invitees = event.invitees.where(status: [
DiscoursePostEvent::Invitee.statuses[:going],
DiscoursePostEvent::Invitee.statuses[:interested]

View File

@ -65,6 +65,18 @@ describe Jobs::DiscoursePostEventSendReminder do
end
end
context 'deleted post' do
let!(:event_1) { Fabricate(:event, post: post_1, reminders: reminders, original_starts_at: 3.hours.from_now) }
it 'is not erroring when post is already deleted' do
post_1.delete
expect {
subject.execute(event_id: event_1.id, reminder: reminders)
}.not_to raise_error
end
end
context 'public event' do
context 'event has not started' do
let!(:event_1) { Fabricate(:event, post: post_1, reminders: reminders, original_starts_at: 3.hours.from_now) }