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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix meeting DST behavior by storing time zone
Oliver Güntherc72d6c279f66
diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 94e231fdd73..09ecceef3d1 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1018,7 +1018,6 @@ en:user_preference:comments_sorting: "Display comments"impaired: "Accessibility mode"- time_zone: "Time zone"auto_hide_popups: "Auto-hide success notifications"warn_on_leaving_unsaved: "Warn me when leaving a work package with unsaved changes"theme: "Mode"@@ -1607,6 +1606,7 @@ en:status: "Status"subject: "Subject"summary: "Summary"+ time_zone: "Time zone"title: "Title"type: "Type"updated_at: "Updated on"diff --git a/modules/meeting/app/models/recurring_meeting.rb b/modules/meeting/app/models/recurring_meeting.rbindex a73a8255c5c..7e8d50caccb 100644--- a/modules/meeting/app/models/recurring_meeting.rb+++ b/modules/meeting/app/models/recurring_meeting.rb@@ -39,7 +39,7 @@ class RecurringMeeting < ApplicationRecordbelongs_to :projectbelongs_to :author, class_name: "User"- validates_presence_of :start_time, :title, :frequency, :end_after+ validates_presence_of :start_time, :title, :frequency, :end_after, :time_zonevalidates_presence_of :end_date, if: -> { end_after_specific_date? }validates_numericality_of :iterations,only_integer: true,@@ -121,6 +121,10 @@ class RecurringMeeting < ApplicationRecordstart_time.day.ordinalizeend+ def start_time+ super&.in_time_zone(time_zone)+ end+def schedule@schedule ||= IceCube::Schedule.new(start_time, duration: template&.duration).tap do |s|s.add_recurrence_rule count_rule(frequency_rule)diff --git a/modules/meeting/app/services/recurring_meetings/set_attributes_service.rb b/modules/meeting/app/services/recurring_meetings/set_attributes_service.rbindex e8c71f00475..7034fee1a97 100644--- a/modules/meeting/app/services/recurring_meetings/set_attributes_service.rb+++ b/modules/meeting/app/services/recurring_meetings/set_attributes_service.rb@@ -42,6 +42,7 @@ module RecurringMeetingsdef set_default_attributes(_params)model.change_by_system do+ model.time_zone = user.time_zone.namemodel.author = usermodel.duration ||= 1enddiff --git a/modules/meeting/db/migrate/20250304082924_add_time_zone_to_recurring_meetings.rb b/modules/meeting/db/migrate/20250304082924_add_time_zone_to_recurring_meetings.rbnew file mode 100644index 00000000000..621b259b6e1--- /dev/null+++ b/modules/meeting/db/migrate/20250304082924_add_time_zone_to_recurring_meetings.rb@@ -0,0 +1,53 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#+++class AddTimeZoneToRecurringMeetings < ActiveRecord::Migration[7.1]+ def change+ add_column :recurring_meetings, :time_zone, :string, null: true++ reversible do |dir|+ dir.up do+ execute <<-SQL.squish+ UPDATE recurring_meetings+ SET time_zone = COALESCE(+ (+ SELECT (user_preferences.settings->>'time_zone')+ FROM user_preferences+ WHERE user_preferences.user_id = recurring_meetings.author_id+ LIMIT 1+ ),+ 'Etc/UTC'+ )+ SQL+ end+ end++ change_column_null :recurring_meetings, :time_zone, false+ end+enddiff --git a/modules/meeting/spec/factories/recurring_meeting_factory.rb b/modules/meeting/spec/factories/recurring_meeting_factory.rbindex cd8462af18b..31a8673391b 100644--- a/modules/meeting/spec/factories/recurring_meeting_factory.rb+++ b/modules/meeting/spec/factories/recurring_meeting_factory.rb@@ -37,6 +37,7 @@ FactoryBot.define dointerval { 1 }iterations { 10 }end_after { "specific_date" }+ time_zone { "UTC" }location { "https://some-url.com" }m.sequence(:title) { |n| "Meeting series #{n}" }diff --git a/modules/meeting/spec/requests/recurring_meetings/recurring_meetings_dst_spec.rb b/modules/meeting/spec/requests/recurring_meetings/recurring_meetings_dst_spec.rbnew file mode 100644index 00000000000..6dfd74e1950--- /dev/null+++ b/modules/meeting/spec/requests/recurring_meetings/recurring_meetings_dst_spec.rb@@ -0,0 +1,100 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++require "spec_helper"+require_relative "../../support/pages/recurring_meeting/show"++RSpec.describe "Recurring meetings show DST",+ :skip_csrf,+ freeze_time: DateTime.parse("2025-03-04T9:00:00Z"),+ type: :rails_request do+ include Redmine::I18n++ shared_let(:project) { create(:project, enabled_module_names: %i[meetings]) }+ shared_let(:berlin_user) do+ create(:user,+ preferences: { time_zone: "Europe/Berlin" },+ member_with_permissions: { project => %i[view_meetings] })+ end+ shared_let(:tokyo_user) do+ create(:user,+ preferences: { time_zone: "Asia/Tokyo" },+ member_with_permissions: { project => %i[view_meetings] })+ end++ shared_let(:recurring_meeting) do+ create :recurring_meeting,+ project:,+ author: berlin_user,+ time_zone: "Europe/Berlin",+ start_time: Time.zone.tomorrow.in_time_zone("Europe/Berlin") + 10.hours, # March 5th, 10AM CET+ frequency: "weekly",+ end_after: "iterations",+ iterations: 10+ end++ let(:current_user) { user }+ let(:request) { get project_recurring_meeting_path(project, recurring_meeting) }+ let(:show_page) { Pages::RecurringMeeting::Show.new(recurring_meeting) }++ before do+ login_as(current_user)+ end++ context "with berlin user and DST approaching" do+ let(:current_user) { berlin_user }++ it "shows a stable 10AM schedule time" do+ request++ expect(page).to have_text "Every week on Wednesday at 10:00 AM, ends on 05/07/2025"+ expect(page).to have_text "March 5, 2025 10:00"+ expect(page).to have_text "March 12, 2025 10:00"+ expect(page).to have_text "March 19, 2025 10:00"+ expect(page).to have_text "March 26, 2025 10:00"+ expect(page).to have_text "April 2, 2025 10:00"+ end+ end++ context "with tokyo user that doesn't have DST" do+ let(:current_user) { tokyo_user }++ it "changes times according to the CET DST" do+ request++ expect(page).to have_text "Every week on Wednesday at 06:00 PM, ends on 05/07/2025"+ expect(page).to have_text "March 5, 2025 18:00"+ expect(page).to have_text "March 12, 2025 18:00"+ expect(page).to have_text "March 19, 2025 18:00"+ expect(page).to have_text "March 26, 2025 18:00"+ expect(page).to have_text "April 2, 2025 17:00"+ end+ end+end