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:
parent
802d56977a
commit
708916b31a
|
@ -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]
|
||||
|
|
|
@ -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) }
|
||||
|
|
Loading…
Reference in New Issue