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

schedule the next occurrence while we're updating

Oliver Günther5d82b7ca5edd
diff --git a/modules/meeting/app/models/recurring_meeting.rb b/modules/meeting/app/models/recurring_meeting.rb
index 927097dcd97..fc1df154344 100644
--- a/modules/meeting/app/models/recurring_meeting.rb
+++ b/modules/meeting/app/models/recurring_meeting.rb
@@ -147,7 +147,7 @@ class RecurringMeeting < ApplicationRecord
end
end
- def full_schedule_in_words
+ def full_schedule_in_words # rubocop:disable Metrics/AbcSize
if has_ended?
I18n.t("recurring_meeting.in_words.full_past",
base: base_schedule,
diff --git a/modules/meeting/app/services/recurring_meetings/update_service.rb b/modules/meeting/app/services/recurring_meetings/update_service.rb
index 80fcf24e97d..9c00ff4253c 100644
--- a/modules/meeting/app/services/recurring_meetings/update_service.rb
+++ b/modules/meeting/app/services/recurring_meetings/update_service.rb
@@ -69,9 +69,8 @@ module RecurringMeetings
# Delete all scheduled jobs for this meeting
GoodJob::Job.where(finished_at: nil, concurrency_key:).delete_all
- InitNextOccurrenceJob
- .set(wait_until: recurring_meeting.next_occurrence.to_time)
- .perform_later(recurring_meeting)
+ # Ensure we init the next meeting directly
+ InitNextOccurrenceJob.perform_now(recurring_meeting, recurring_meeting.next_occurrence.to_time)
end
def should_reschedule?(recurring_meeting)
diff --git a/modules/meeting/app/views/recurring_meetings/_show_upcoming.html.erb b/modules/meeting/app/views/recurring_meetings/_show_upcoming.html.erb
index dc82f85fe84..1653379bf8b 100644
--- a/modules/meeting/app/views/recurring_meetings/_show_upcoming.html.erb
+++ b/modules/meeting/app/views/recurring_meetings/_show_upcoming.html.erb
@@ -28,14 +28,16 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<% if @recurring_meeting.has_ended? -%>
- <%= render(Primer::Beta::Blankslate.new(border: true)) do |component|
- component.with_visual_icon(icon: :book)
- component.with_heading(tag: :h2).with_content(t("recurring_meeting.ended_blankslate.title"))
- component.with_description do
- concat render(Primer::Beta::Text.new(tag: :p, color: :subtle)) { t("recurring_meeting.ended_blankslate.message")}
- concat render(Primer::Beta::Text.new(tag: :p, color: :subtle)) { t("recurring_meeting.ended_blankslate.action")}
+ <%=
+ render(Primer::Beta::Blankslate.new(border: true)) do |component|
+ component.with_visual_icon(icon: :book)
+ component.with_heading(tag: :h2).with_content(t("recurring_meeting.ended_blankslate.title"))
+ component.with_description do
+ concat render(Primer::Beta::Text.new(tag: :p, color: :subtle)) { t("recurring_meeting.ended_blankslate.message") }
+ concat render(Primer::Beta::Text.new(tag: :p, color: :subtle)) { t("recurring_meeting.ended_blankslate.action") }
+ end
end
- end %>
+ %>
<% else -%>
<%= render RecurringMeetings::TableHeaderComponent.new(
meeting: @recurring_meeting,
diff --git a/modules/meeting/spec/models/recurring_meeting_spec.rb b/modules/meeting/spec/models/recurring_meeting_spec.rb
index c9b2ca6021a..c1a6acd0915 100644
--- a/modules/meeting/spec/models/recurring_meeting_spec.rb
+++ b/modules/meeting/spec/models/recurring_meeting_spec.rb
@@ -219,7 +219,7 @@ RSpec.describe RecurringMeeting,
it "schedules daily", :aggregate_failures do
expect(subject.first_occurrence).to eq Time.zone.tomorrow + 10.hours
expect(subject.remaining_occurrences).to be_nil
- expect { subject.last_occurrence }.to raise_error(ArgumentError)
+ expect(subject.last_occurrence).to be_nil
end
end
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 552217e0916..a50e8afc907 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
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -46,6 +48,7 @@ RSpec.describe "Recurring meetings show",
let(:current_user) { user }
let(:show_page) { Pages::RecurringMeeting::Show.new(recurring_meeting).with_capybara_page(page) }
+ let(:request) { get recurring_meeting_path(recurring_meeting) }
before do
login_as(current_user)
@@ -61,6 +64,32 @@ RSpec.describe "Recurring meetings show",
get project_recurring_meeting_path(project, recurring_meeting)
expect(response).to have_http_status(:ok)
end
+
+ context "when the meeting has and end_date < today" do
+ before do
+ recurring_meeting.update_columns(end_date: Time.zone.yesterday)
+ end
+
+ it "shows the appropriate blankslate and text" do
+ request
+ expect(page).to have_text "Meeting series ended"
+ expect(page).to have_text "ended on #{format_date(Time.zone.yesterday)}"
+ end
+ end
+
+ context "when the meeting has no end_date, but iterations" do
+ before do
+ recurring_meeting.update_columns(end_after: "iterations",
+ iterations: 2,
+ start_time: Time.zone.today - 3.days + 10.hours)
+ end
+
+ it "shows the blankslate for two days ago" do
+ request
+ expect(page).to have_text "Meeting series ended"
+ expect(page).to have_text "ended on #{format_date(Time.zone.today - 2.days)}"
+ end
+ end
end
describe "past quick filter" do
diff --git a/modules/meeting/spec/services/recurring_meetings/update_service_integration_spec.rb b/modules/meeting/spec/services/recurring_meetings/update_service_integration_spec.rb
index 11aab02ae46..333bceca20b 100644
--- a/modules/meeting/spec/services/recurring_meetings/update_service_integration_spec.rb
+++ b/modules/meeting/spec/services/recurring_meetings/update_service_integration_spec.rb
@@ -108,7 +108,7 @@ RSpec.describe RecurringMeetings::UpdateService, "integration", type: :model do
.perform_later(series)
end
- it "reschedules" do
+ it "reschedules and enqueues the next job" do
job = GoodJob::Job.find_by(job_class: "RecurringMeetings::InitNextOccurrenceJob")
expect(job.scheduled_at).to eq Time.zone.today + 1.day + 10.hours
expect(service_result).to be_success
@@ -116,6 +116,8 @@ RSpec.describe RecurringMeetings::UpdateService, "integration", type: :model do
new_job = GoodJob::Job.find_by(job_class: "RecurringMeetings::InitNextOccurrenceJob")
expect(new_job.scheduled_at).to eq Time.zone.today + 2.days + 11.hours
+
+ expect(series.upcoming_instantiated_meetings.count).to eq 1
end
end
end