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
Reminder note should not be more than 80 chars
Kabiru Mwenja9627c5b8fc7f
diff --git a/app/contracts/reminders/base_contract.rb b/app/contracts/reminders/base_contract.rbindex abdf358a7a1..b539f96f636 100644--- a/app/contracts/reminders/base_contract.rb+++ b/app/contracts/reminders/base_contract.rb@@ -28,6 +28,8 @@module Remindersclass BaseContract < ::ModelContract+ MAX_NOTE_CHARS_LENGTH = 80+attribute :creator_idattribute :remindable_idattribute :remindable_type@@ -39,6 +41,7 @@ module Remindersvalidate :validate_remindable_existsvalidate :validate_manage_reminders_permissionsvalidate :validate_remind_at_is_in_future+ validate :validate_note_lengthdef self.model = Reminder@@ -62,6 +65,12 @@ module Remindersendend+ def validate_note_length+ if model.note.present? && model.note.length > MAX_NOTE_CHARS_LENGTH+ errors.add :note, :too_long, count: MAX_NOTE_CHARS_LENGTH+ end+ end+def validate_manage_reminders_permissionsreturn if errors.added?(:remindable, :not_found)diff --git a/spec/contracts/reminders/base_contract_spec.rb b/spec/contracts/reminders/base_contract_spec.rbindex 3005a15155f..1dc9fcd654d 100644--- a/spec/contracts/reminders/base_contract_spec.rb+++ b/spec/contracts/reminders/base_contract_spec.rb@@ -119,5 +119,19 @@ RSpec.describe Reminders::BaseContract doendend+ describe "validate note length" do+ context "when note is too long" do+ before { reminder.note = "a" * (described_class::MAX_NOTE_CHARS_LENGTH + 1) }++ it_behaves_like "contract is invalid", note: :too_long+ end++ context "when note is within the limit" do+ before { reminder.note = "a" * described_class::MAX_NOTE_CHARS_LENGTH }++ it_behaves_like "contract is valid"+ end+ end+include_examples "contract reuses the model errors"end