Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion modules/meeting/app/controllers/recurring_meetings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,16 @@ def new
@recurring_meeting = RecurringMeeting.new(project: @project)
end

def init
def init # rubocop:disable Metrics/AbcSize
scheduled_meeting = @recurring_meeting.scheduled_meetings.find_by(start_time: params[:start_time])
is_restoration = scheduled_meeting&.cancelled?

call = ::RecurringMeetings::InitOccurrenceService
.new(user: current_user, recurring_meeting: @recurring_meeting)
.call(start_time: DateTime.iso8601(params[:start_time]))

if call.success?
send_restoration_notifications(call.result) if is_restoration
redirect_to project_meeting_path(call.result.project, call.result), status: :see_other
else
flash[:error] = call.message
Expand Down Expand Up @@ -269,6 +273,22 @@ def deliver_invitation_mails
end
end

def send_restoration_notifications(meeting)
return unless meeting.notify?

meeting
.participants
.invited
.find_each do |participant|
MeetingMailer
.invited(
meeting,
participant.user,
User.current
).deliver_later
end
end

def upcoming_meetings(count:)
opened = @recurring_meeting
.upcoming_instantiated_meetings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,28 @@
show_page.expect_cancelled_meeting date: "01/07/2025 01:30 PM"
end

it "sends an email notification when restoring a cancelled planned occurrence" do
meeting.template.update(notify: true)
show_page.visit!

show_page.cancel_occurrence date: "01/07/2025 01:30 PM"
show_page.within_modal "Cancel meeting occurrence" do
click_on "Cancel occurrence"
end

expect_flash(type: :success, message: "Successful cancellation.")
show_page.expect_cancelled_meeting date: "01/07/2025 01:30 PM"

show_page.restore date: "01/07/2025 01:30 PM"
wait_for_reload

ActionMailer::Base.deliveries.clear

perform_enqueued_jobs
expect(ActionMailer::Base.deliveries.size).to eq 1
expect(ActionMailer::Base.deliveries.last.subject).to eq("[#{project.name}] #{meeting.template.title}")
end

it "can edit the details of a recurring meeting" do
show_page.visit!

Expand Down Expand Up @@ -188,6 +210,28 @@
show_page.expect_cancelled_actions date: "12/31/2024 01:30 PM"
end

it "sends restoration notification when restoring a cancelled open occurrence" do
meeting.template.update(notify: true)
show_page.visit!

show_page.cancel_occurrence date: "12/31/2024 01:30 PM"
show_page.within_modal "Cancel meeting occurrence" do
click_on "Cancel occurrence"
end

expect_flash(type: :success, message: "Successful cancellation.")
show_page.expect_cancelled_meeting date: "12/31/2024 01:30 PM"

show_page.restore date: "12/31/2024 01:30 PM"
wait_for_reload

ActionMailer::Base.deliveries.clear

perform_enqueued_jobs
expect(ActionMailer::Base.deliveries.size).to eq 1
expect(ActionMailer::Base.deliveries.last.subject).to eq("[#{project.name}] #{meeting.template.title}")
end

it "can edit the meeting series interval when created with working days (Regression #62089)" do
meeting.update!(frequency: "working_days")

Expand Down
7 changes: 7 additions & 0 deletions modules/meeting/spec/support/pages/recurring_meeting/show.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ def open(date:)
end
end

def restore(date:)
within("li", text: date) do
click_on "more-button"
click_on "Restore this occurrence"
end
end

def cancel_occurrence(date:)
within("li", text: date) do
click_on "more-button"
Expand Down
Loading