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
Adjust error messages
Dombi Attilad4636bc2d72c
diff --git a/app/contracts/relations/base_contract.rb b/app/contracts/relations/base_contract.rbindex eaf0ebbe408..82c4d5edc2e 100644--- a/app/contracts/relations/base_contract.rb+++ b/app/contracts/relations/base_contract.rb@@ -39,7 +39,6 @@ module Relationsvalidate :validate_to_existsvalidate :validate_nodes_relatablevalidate :validate_accepted_type- validate :validate_lag_numericalitydef self.modelRelation@@ -74,16 +73,6 @@ module Relationsendend- def validate_lag_numericality- if model.lag.present?- if model.lag < 0- errors.add :lag, I18n.t(:"activerecord.errors.messages.circular_dependency")- elsif model.lag > 2_147_483_647- errors.add :lag, I18n.t(:"activerecord.errors.models.relation.attributes.lag.high_value")- end- end- end-def visible_work_packages::WorkPackage.visible(user)enddiff --git a/app/models/relation.rb b/app/models/relation.rbindex eb56291542f..fd56d0af358 100644--- a/app/models/relation.rb+++ b/app/models/relation.rb@@ -106,14 +106,7 @@ class Relation < ApplicationRecordvalidates :lag, numericality: {allow_nil: true,less_than_or_equal_to: 2_147_483_647,- greater_than_or_equal_to: 0,- message: ->(_, data) {- if data[:value] < 0- I18n.t("activerecord.errors.models.relation.attributes.lag.negative_value")- else- I18n.t("activerecord.errors.models.relation.attributes.lag.high_value")- end- }+ greater_than_or_equal_to: 0}validates :to, uniqueness: { scope: :from }diff --git a/config/locales/en.yml b/config/locales/en.ymlindex a99cb348827..e075a6954ea 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1308,8 +1308,9 @@ en:error_not_found: "work package in `from` position not found or not visible"error_readonly: "an existing relation's `from` link is immutable"lag:- high_value: "The value for lag is too high."- negative_value: "Lag cannot be negative."+ greater_than_or_equal_to:+ zero: "cannot be negative."+ less_than_or_equal_to: "is too high."repository:not_available: "SCM vendor is not available"not_whitelisted: "is not allowed by the configuration."diff --git a/spec/models/relation_spec.rb b/spec/models/relation_spec.rbindex 32252836b1e..d76a0a311ef 100644--- a/spec/models/relation_spec.rb+++ b/spec/models/relation_spec.rb@@ -38,11 +38,12 @@ RSpec.describe Relation doit "validates lag numericality" dorelation.lag = -1expect(relation).not_to be_valid- expect(relation.errors[:lag]).to include(I18n.t(:"activerecord.errors.models.relation.attributes.lag.negative_value"))+ expect(relation.errors[:lag])+ .to include(I18n.t(:"activerecord.errors.models.relation.attributes.lag.greater_than_or_equal_to.zero"))relation.lag = 2_147_483_648expect(relation).not_to be_valid- expect(relation.errors[:lag]).to include(I18n.t(:"activerecord.errors.models.relation.attributes.lag.high_value"))+ expect(relation.errors[:lag]).to include(I18n.t(:"activerecord.errors.models.relation.attributes.lag.less_than_or_equal_to"))relation.lag = 1_000expect(relation).to be_valid