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
bug/64695 Upon setting a work package reminder, present the reminder time in relative humanized format (#19230)
Kabiru Mwenjae097974c62a5
diff --git a/app/controllers/work_packages/reminders_controller.rb b/app/controllers/work_packages/reminders_controller.rbindex 250390be0e6..d47d0e9bedf 100644--- a/app/controllers/work_packages/reminders_controller.rb+++ b/app/controllers/work_packages/reminders_controller.rb@@ -30,7 +30,10 @@class WorkPackages::RemindersController < ApplicationControllerinclude OpTurbo::ComponentStream+ include Redmine::I18n+layout false+before_action :find_work_packagebefore_action :find_or_build_reminder, only: %i[modal_body create]before_action :find_reminder, only: %i[update destroy]@@ -50,7 +53,9 @@ class WorkPackages::RemindersController < ApplicationController.call(reminder_params)if service_result.success?- respond_with_success_flash_message(message: I18n.t("work_package.reminders.success_creation_message"))+ message = I18n.t("work_package.reminders.create_success_message",+ reminder_time: reminder_chosen_time(service_result.result)).html_safe+ respond_with_success_flash_message(message:)elserespond_with_error_modal_component(service_result)end@@ -102,6 +107,12 @@ class WorkPackages::RemindersController < ApplicationControllerrespond_with_turbo_streams(status: :unprocessable_entity)end+ def reminder_chosen_time(reminder)+ OpPrimer::RelativeTimeComponent.new(+ datetime: in_user_zone(reminder.remind_at)+ ).render_in(view_context)+ end+def find_work_package@work_package = WorkPackage.visible.find(params[:work_package_id])enddiff --git a/config/locales/en.yml b/config/locales/en.ymlindex c1d75179c6f..414e8fdf61d 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -4541,7 +4541,7 @@ en:reminders:label_remind_at: "Date"note_placeholder: "Why are you setting this reminder?"- success_creation_message: "Reminder set successfully. You will receive a notification for this work package at the chosen time."+ create_success_message: "Reminder set successfully. You will receive a notification for this work package %{reminder_time}."success_update_message: "Reminder updated successfully."success_deletion_message: "Reminder deleted successfully."sharing:diff --git a/spec/features/work_packages/reminders_spec.rb b/spec/features/work_packages/reminders_spec.rbindex c3988842868..9fd51cab04c 100644--- a/spec/features/work_packages/reminders_spec.rb+++ b/spec/features/work_packages/reminders_spec.rb@@ -76,16 +76,21 @@ 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- # 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 "Time", with: time.strftime("%H:%M").to_timefill_in "Note", with: "Never forget!"click_link_or_button "Set reminder"end- work_package_page.expect_and_dismiss_flash(type: :success,- message: I18n.t("work_package.reminders.success_creation_message"))+ # Relative time is rendered as a dynamic component that is a not assertable as text in capybara+ within_test_selector("op-primer-flash-message") do+ expect(find("relative-time")[:datetime]).to eq(time.iso8601)+ end++ work_package_page.expect_and_dismiss_flash(+ type: :success,+ message: /Reminder set successfully\. You will receive a notification for this work package .+/+ )work_package_page.expect_reminder_button_alarm_set_iconexpect(Reminder.last)@@ -187,17 +192,12 @@ RSpec.describe "Work package reminder modal",describe "validations" doit "renders errors on the date field or time field when the reminder is in the past" do- two_am = Time.zone.parse("02:00")- thirty_minutes_ago = 30.minutes.ago- .in_time_zone(current_user.time_zone)- .strftime("%H:%M")- .to_time- thirty_minutes_from_now = 30.minutes.from_now- .in_time_zone(current_user.time_zone)- .strftime("%H:%M")- .to_time- yesterday = Time.current.in_time_zone(current_user.time_zone).yesterday.to_date- today = Time.current.in_time_zone(current_user.time_zone).to_date+ now = Time.now.in_time_zone(current_user.time_zone)+ two_am = now.change(hour: 2, minute: 0, second: 0)+ thirty_minutes_ago = (now - 30.minutes).strftime("%H:%M")+ thirty_minutes_from_now = (now + 30.minutes).strftime("%H:%M")+ yesterday = (now - 1.day).to_date+ today = now.to_datework_package_page.visit!work_package_page.click_reminder_button_with_context_menu@@ -221,7 +221,7 @@ RSpec.describe "Work package reminder modal",# 30 minutes agofill_in "Date", with: today- fill_in "Time", with: thirty_minutes_ago+ fill_in "Time", with: thirty_minutes_ago.to_timeclick_link_or_button "Set reminder"wait_for_network_idle@@ -229,14 +229,22 @@ RSpec.describe "Work package reminder modal",# 30 minutes from nowfill_in "Date", with: today- fill_in "Time", with: thirty_minutes_from_now+ fill_in "Time", with: thirty_minutes_from_now.to_timeclick_link_or_button "Set reminder"wait_for_network_idleend- work_package_page.expect_and_dismiss_flash(type: :success,- message: I18n.t("work_package.reminders.success_creation_message"))+ # Relative time is rendered as a dynamic component that is a not assertable as text in capybara+ within_test_selector("op-primer-flash-message") do+ expect(find("relative-time")[:datetime])+ .to eq(current_user.time_zone.parse("#{today} #{thirty_minutes_from_now}").iso8601)+ end++ work_package_page.expect_and_dismiss_flash(+ type: :success,+ message: /Reminder set successfully\. You will receive a notification for this work package .+/+ )work_package_page.expect_reminder_button_alarm_set_iconend