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 setting direction for past meetings count

Oliver Günthera36e53b5bf7b
diff --git a/modules/meeting/app/controllers/recurring_meetings_controller.rb b/modules/meeting/app/controllers/recurring_meetings_controller.rb
index 7518dcad936..792cb0a0503 100644
--- a/modules/meeting/app/controllers/recurring_meetings_controller.rb
+++ b/modules/meeting/app/controllers/recurring_meetings_controller.rb
@@ -18,6 +18,7 @@ class RecurringMeetingsController < ApplicationController
before_action :authorize, except: %i[index new create]
before_action :get_scheduled_meeting, only: %i[delete_scheduled_dialog destroy_scheduled]
+ before_action :set_direction, only: %i[show]
before_action :convert_params, only: %i[create update]
before_action :check_template_completable, only: %i[template_completed]
before_action :build_meeting_limits, only: %i[show]
@@ -46,8 +47,6 @@ class RecurringMeetingsController < ApplicationController
end
def show # rubocop:disable Metrics/AbcSize
- @direction = params[:direction]
-
if @direction == "past"
@meetings = @recurring_meeting.scheduled_instances(upcoming: false).limit(@count)
else
@@ -278,6 +277,10 @@ class RecurringMeetingsController < ApplicationController
[opened.values.sort_by(&:start_time), planned]
end
+ def set_direction
+ @direction = params[:direction]
+ end
+
def build_meeting_limits
@max_count =
if @direction == "past"
diff --git a/modules/meeting/spec/requests/recurring_meetings/recurring_meetings_show_spec.rb b/modules/meeting/spec/requests/recurring_meetings/recurring_meetings_show_spec.rb
index a50e8afc907..e208515466c 100644
--- a/modules/meeting/spec/requests/recurring_meetings/recurring_meetings_show_spec.rb
+++ b/modules/meeting/spec/requests/recurring_meetings/recurring_meetings_show_spec.rb
@@ -115,6 +115,17 @@ RSpec.describe "Recurring meetings show",
expect(page).to have_no_text format_time(past_schedule_cancelled.start_time)
expect(page).to have_no_css("li", text: "Cancelled")
end
+
+ context "when meeting has ended and no upcoming meetings remain" do
+ before do
+ recurring_meeting.update_columns(end_date: Time.zone.yesterday)
+ end
+
+ it "still shows the one past meeting (Regression #61280)" do
+ get recurring_meeting_path(recurring_meeting, direction: "past")
+ expect(page).to have_text format_time(past_instance.start_time)
+ end
+ end
end
describe "upcoming tab" do