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 timezone parsing for reminder form and tests
Klaus Zanderscbe5c5d8957a
diff --git a/app/controllers/work_packages/reminders_controller.rb b/app/controllers/work_packages/reminders_controller.rbindex 0b4796824ab..43fe55baa37 100644--- a/app/controllers/work_packages/reminders_controller.rb+++ b/app/controllers/work_packages/reminders_controller.rb@@ -184,7 +184,7 @@ class WorkPackages::RemindersController < ApplicationControllerdef build_remind_at_from_params(remind_at_date, remind_at_time)if remind_at_date.present? && remind_at_time.present?- DateTime.parse("#{remind_at_date} #{User.current.time_zone.parse(remind_at_time)}")+ User.current.time_zone.parse("#{remind_at_date} #{remind_at_time}")endenddiff --git a/spec/features/work_packages/reminders_spec.rb b/spec/features/work_packages/reminders_spec.rbindex 64cf2d772cd..0a12d740d27 100644--- a/spec/features/work_packages/reminders_spec.rb+++ b/spec/features/work_packages/reminders_spec.rb@@ -42,12 +42,9 @@ RSpec.describe "Work package reminder modal",endlet!(:user_with_permissions) do- local_offset = Time.now.gmt_offset # rubocop:disable Rails/TimeZone- time_zone = UserPreferences::UpdateContract.assignable_time_zones- .find { |tz| tz.now.utc_offset == local_offset }create(:user,member_with_roles: { project => role_that_allows_managing_own_reminders },- preferences: { time_zone: time_zone.tzinfo.canonical_zone.name })+ preferences: { time_zone: "Europe/Berlin" })endlet!(:user_without_permissions) docreate(:user,@@ -66,8 +63,8 @@ RSpec.describe "Work package reminder modal",endspecify "can create a reminder, subsequently update it and delete it" do- date = Date.current + 2.weeks- time = Time.zone.parse("05:00")+ time = (current_user.time_zone.now + 2.weeks).change(hour: 12, minute: 0, second: 0)+ date = time.to_datework_package_page.visit!work_package_page.click_reminder_button@@ -79,7 +76,9 @@ RSpec.describe "Work package reminder modal",.to have_css(".spot-modal--subheader",text: "You will receive a notification for this work package at the chosen time.")fill_in "Date", with: date- fill_in "Time", with: time+ # capybara expets us to set a full timestamp here, eventhough the+ # input is only for time and the date portion is irrelevant+ fill_in "Time", with: "1970-01-01T#{time.strftime('%H:%M')}"fill_in "Note", with: "Never forget!"click_link_or_button "Set reminder"@@ -93,7 +92,7 @@ RSpec.describe "Work package reminder modal",.to have_attributes(remindable: work_package,creator: user_with_permissions,- remind_at: DateTime.parse("#{date} #{time}"),+ remind_at: time,note: "Never forget!")@@ -106,7 +105,7 @@ RSpec.describe "Work package reminder modal",.to have_css(".spot-modal--subheader",text: "You will receive a notification for this work package at the chosen time.")expect(page).to have_field("Date", with: date)- expect(page).to have_field("Time", with: time.in_time_zone(current_user.time_zone).strftime("%H:%M"))+ expect(page).to have_field("Time", with: time.strftime("%H:%M"))expect(page).to have_field("Note", with: "Never forget!")expect(page).to have_button("Save")@@ -120,7 +119,7 @@ RSpec.describe "Work package reminder modal",.to have_attributes(remindable: work_package,creator: user_with_permissions,- remind_at: DateTime.parse("#{date} #{time}"),+ remind_at: time,note: "Remember to never forget!")