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
Change multiple reminders restriction to HTTP 409
Kabiru Mwenja4b1f4c9729cb
diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 33d90556ca8..f0e9ca42cda 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -4579,6 +4579,7 @@ en:code_500_missing_enterprise_token: "The request can not be handled due to invalid or missing Enterprise token."bad_request:emoji_reactions_activity_type_not_supported: "This activity type does not support emoji reactions."+ conflict:multiple_reminders_not_allowed: |-You can only set one reminder at a time for a work package. Please delete or update the existing reminder.not_found:diff --git a/docs/api/apiv3/paths/work_package_reminders.yml b/docs/api/apiv3/paths/work_package_reminders.ymlindex 7e2e1bc6b20..cf9a8fe8506 100644--- a/docs/api/apiv3/paths/work_package_reminders.yml+++ b/docs/api/apiv3/paths/work_package_reminders.yml@@ -112,20 +112,20 @@ post:application/hal+json:schema:$ref: '../components/schemas/reminder_model.yml'- '400':+ '404':description: |-- Returned if the user already has an active reminder for this work package.+ Returned if the work package does not exist or the client does not have sufficient permissions to see it.- **Error message**: You can only set one reminder at a time for a work package. Please delete or update the existing reminder.+ **Required permission:** view work packagecontent:application/hal+json:schema:$ref: '../components/schemas/error_response.yml'- '404':+ '409':description: |-- Returned if the work package does not exist or the client does not have sufficient permissions to see it.+ Returned if the user already has an active reminder for this work package.- **Required permission:** view work package+ **Error message**: You can only set one reminder at a time for a work package. Please delete or update the existing reminder.content:application/hal+json:schema:diff --git a/lib/api/v3/reminders/reminders_api.rb b/lib/api/v3/reminders/reminders_api.rbindex 4484f735587..f2b9999f571 100644--- a/lib/api/v3/reminders/reminders_api.rb+++ b/lib/api/v3/reminders/reminders_api.rb@@ -42,8 +42,8 @@ module APIdef restrict_multiple_remindersif reminders.any?- raise ::API::Errors::BadRequest.new(- I18n.t("api_v3.errors.bad_request.multiple_reminders_not_allowed")+ raise ::API::Errors::Conflict.new(+ message: I18n.t("api_v3.errors.conflict.multiple_reminders_not_allowed"))endenddiff --git a/spec/requests/api/v3/reminders/reminders_api_spec.rb b/spec/requests/api/v3/reminders/reminders_api_spec.rbindex 4d6f7416e31..96b101fee47 100644--- a/spec/requests/api/v3/reminders/reminders_api_spec.rb+++ b/spec/requests/api/v3/reminders/reminders_api_spec.rb@@ -181,7 +181,7 @@ RSpec.describe API::V3::Reminders::RemindersAPI dobefore { make_request }it_behaves_like "error response",- 400, "BadRequest",+ 409, "UpdateConflict","You can only set one reminder at a time for a work package. Please delete or update the existing reminder."end