Skip to content

Commit 8974021

Browse files
authored
Merge pull request #21586 from opf/bug/70113-missing-notification-when-restoring-a-cancelled-occurrence
[#70113] Missing notification when restoring a cancelled occurrence
2 parents b76ad69 + 2414808 commit 8974021

File tree

3 files changed

+72
-1
lines changed

3 files changed

+72
-1
lines changed

modules/meeting/app/controllers/recurring_meetings_controller.rb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,16 @@ def new
5757
@recurring_meeting = RecurringMeeting.new(project: @project)
5858
end
5959

60-
def init
60+
def init # rubocop:disable Metrics/AbcSize
61+
scheduled_meeting = @recurring_meeting.scheduled_meetings.find_by(start_time: params[:start_time])
62+
is_restoration = scheduled_meeting&.cancelled?
63+
6164
call = ::RecurringMeetings::InitOccurrenceService
6265
.new(user: current_user, recurring_meeting: @recurring_meeting)
6366
.call(start_time: DateTime.iso8601(params[:start_time]))
6467

6568
if call.success?
69+
send_restoration_notifications(call.result) if is_restoration
6670
redirect_to project_meeting_path(call.result.project, call.result), status: :see_other
6771
else
6872
flash[:error] = call.message
@@ -269,6 +273,22 @@ def deliver_invitation_mails
269273
end
270274
end
271275

276+
def send_restoration_notifications(meeting)
277+
return unless meeting.notify?
278+
279+
meeting
280+
.participants
281+
.invited
282+
.find_each do |participant|
283+
MeetingMailer
284+
.invited(
285+
meeting,
286+
participant.user,
287+
User.current
288+
).deliver_later
289+
end
290+
end
291+
272292
def upcoming_meetings(count:)
273293
opened = @recurring_meeting
274294
.upcoming_instantiated_meetings

modules/meeting/spec/features/recurring_meetings/recurring_meeting_crud_spec.rb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,28 @@
147147
show_page.expect_cancelled_meeting date: "01/07/2025 01:30 PM"
148148
end
149149

150+
it "sends an email notification when restoring a cancelled planned occurrence" do
151+
meeting.template.update(notify: true)
152+
show_page.visit!
153+
154+
show_page.cancel_occurrence date: "01/07/2025 01:30 PM"
155+
show_page.within_modal "Cancel meeting occurrence" do
156+
click_on "Cancel occurrence"
157+
end
158+
159+
expect_flash(type: :success, message: "Successful cancellation.")
160+
show_page.expect_cancelled_meeting date: "01/07/2025 01:30 PM"
161+
162+
show_page.restore date: "01/07/2025 01:30 PM"
163+
wait_for_reload
164+
165+
ActionMailer::Base.deliveries.clear
166+
167+
perform_enqueued_jobs
168+
expect(ActionMailer::Base.deliveries.size).to eq 1
169+
expect(ActionMailer::Base.deliveries.last.subject).to eq("[#{project.name}] #{meeting.template.title}")
170+
end
171+
150172
it "can edit the details of a recurring meeting" do
151173
show_page.visit!
152174

@@ -188,6 +210,28 @@
188210
show_page.expect_cancelled_actions date: "12/31/2024 01:30 PM"
189211
end
190212

213+
it "sends restoration notification when restoring a cancelled open occurrence" do
214+
meeting.template.update(notify: true)
215+
show_page.visit!
216+
217+
show_page.cancel_occurrence date: "12/31/2024 01:30 PM"
218+
show_page.within_modal "Cancel meeting occurrence" do
219+
click_on "Cancel occurrence"
220+
end
221+
222+
expect_flash(type: :success, message: "Successful cancellation.")
223+
show_page.expect_cancelled_meeting date: "12/31/2024 01:30 PM"
224+
225+
show_page.restore date: "12/31/2024 01:30 PM"
226+
wait_for_reload
227+
228+
ActionMailer::Base.deliveries.clear
229+
230+
perform_enqueued_jobs
231+
expect(ActionMailer::Base.deliveries.size).to eq 1
232+
expect(ActionMailer::Base.deliveries.last.subject).to eq("[#{project.name}] #{meeting.template.title}")
233+
end
234+
191235
it "can edit the meeting series interval when created with working days (Regression #62089)" do
192236
meeting.update!(frequency: "working_days")
193237

modules/meeting/spec/support/pages/recurring_meeting/show.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ def open(date:)
9393
end
9494
end
9595

96+
def restore(date:)
97+
within("li", text: date) do
98+
click_on "more-button"
99+
click_on "Restore this occurrence"
100+
end
101+
end
102+
96103
def cancel_occurrence(date:)
97104
within_row(date) do
98105
click_on "more-button"

0 commit comments

Comments
 (0)