Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix meeting occurrence count

Oliver Günther86c69e377d2b
diff --git a/modules/meeting/app/components/recurring_meetings/delete_dialog_component.rb b/modules/meeting/app/components/recurring_meetings/delete_dialog_component.rb
index 6abf3e86201..b9cf1d2450f 100644
--- a/modules/meeting/app/components/recurring_meetings/delete_dialog_component.rb
+++ b/modules/meeting/app/components/recurring_meetings/delete_dialog_component.rb
@@ -49,7 +49,7 @@ module RecurringMeetings
def confirmation_message
t("recurring_meeting.delete_dialog.confirmation_message_html",
title: @recurring_meeting.title,
- count: @recurring_meeting.remaining_occurrences&.count || 0) # actually ♾️, but we show same message as for 0
+ count: @recurring_meeting.instantiated_meetings.count)
end
end
end
diff --git a/modules/meeting/app/controllers/recurring_meetings_controller.rb b/modules/meeting/app/controllers/recurring_meetings_controller.rb
index b2d5f179aad..a58102c9a4c 100644
--- a/modules/meeting/app/controllers/recurring_meetings_controller.rb
+++ b/modules/meeting/app/controllers/recurring_meetings_controller.rb
@@ -272,7 +272,7 @@ class RecurringMeetingsController < ApplicationController
.scheduled_occurrences(limit: count + opened.count)
.reject { |start_time| opened.include?(start_time) }
.map { |start_time| cancelled[start_time] || scheduled_meeting(start_time) }
- .first(count)
+ .first([count, 0].max)
[opened.values.sort_by(&:start_time), planned]
end
diff --git a/modules/meeting/app/models/recurring_meeting.rb b/modules/meeting/app/models/recurring_meeting.rb
index bef5e839c9a..1c5649e2a06 100644
--- a/modules/meeting/app/models/recurring_meeting.rb
+++ b/modules/meeting/app/models/recurring_meeting.rb
@@ -232,6 +232,10 @@ class RecurringMeeting < ApplicationRecord
.order(start_time: :asc)
end
+ def instantiated_meetings
+ meetings.not_templated
+ end
+
private
def unset_schedule
diff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.yml
index 99d34a27655..80704b25893 100644
--- a/modules/meeting/config/locales/en.yml
+++ b/modules/meeting/config/locales/en.yml
@@ -312,13 +312,13 @@ en:
heading: "Permanently delete this meeting series?"
confirmation_message_html:
zero: >
- Deleting <strong>%{title}</strong> will delete any meetings in this series.
- This action is not reversible. Please proceed with caution.
+ The meeting series <strong>%{title}</strong> does not have any meeting occurrences.
+ The series will be deleted for everyone. Please proceed with caution.
one: >
- Deleting <strong>%{title}</strong> will also delete one meeting in this series.
+ Deleting <strong>%{title}</strong> will also delete one occurrence in this series.
This action is not reversible. Please proceed with caution.
other: >
- Deleting <strong>%{title}</strong> will delete all %{count} meetings in this series.
+ Deleting <strong>%{title}</strong> will delete all %{count} occurrences in this series.
This action is not reversible. Please proceed with caution.
scheduled_delete_dialog:
diff --git a/modules/meeting/spec/components/recurring_meetings/delete_dialog_component_spec.rb b/modules/meeting/spec/components/recurring_meetings/delete_dialog_component_spec.rb
index 6e7e94feebe..0c6cde5d955 100644
--- a/modules/meeting/spec/components/recurring_meetings/delete_dialog_component_spec.rb
+++ b/modules/meeting/spec/components/recurring_meetings/delete_dialog_component_spec.rb
@@ -71,23 +71,14 @@ RSpec.describe RecurringMeetings::DeleteDialogComponent, type: :component do
context "with a meeting series that ends - with several remaining meetings" do
it "shows a confirmation message with a count of the remaining meetings" do
- expect(subject).to have_text "will delete all 6 meetings in this series"
+ expect(subject).to have_text "does not have any meeting occurrences"
end
end
- context "with a meeting series that ends - with one remaining meeting" do
- let(:recurring_meeting) { build_stubbed(:recurring_meeting, project:, end_after: :iterations, iterations: 1) }
-
+ context "with a meeting series that has an occurrence" do
it "shows a confirmation message mentioning one remaining meeting" do
- expect(subject).to have_text "will also delete one meeting in this series"
- end
- end
-
- context "with a meeting series that never ends" do
- let(:recurring_meeting) { build_stubbed(:recurring_meeting, project:, end_after: :never) }
-
- it "shows a confirmation message without a count" do
- expect(subject).to have_text "will delete any meetings in this series"
+ allow(recurring_meeting).to receive(:instantiated_meetings).and_return([meeting])
+ expect(subject).to have_text "will also delete one occurrence in this series"
end
end
end