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
Normalize AttributeHelpText#attribute_name
Alexander Brandon Coles33de48f8c77d
diff --git a/app/models/attribute_help_text.rb b/app/models/attribute_help_text.rbindex a138103f83e..fb0f2f30aa2 100644--- a/app/models/attribute_help_text.rb+++ b/app/models/attribute_help_text.rb@@ -62,6 +62,8 @@ class AttributeHelpText < ApplicationRecordscopeend+ normalizes :attribute_name, with: -> { it.delete_suffix("_id") }+validates :help_text, presence: truevalidates :attribute_name, uniqueness: { scope: :type }diff --git a/spec/models/attribute_help_text/project_spec.rb b/spec/models/attribute_help_text/project_spec.rbindex 7132d9745ba..6e56f1ece26 100644--- a/spec/models/attribute_help_text/project_spec.rb+++ b/spec/models/attribute_help_text/project_spec.rb@@ -111,6 +111,12 @@ RSpec.describe AttributeHelpText::Project doendend+ describe "normalization" do+ it "normalizes attribute_name" do+ expect(subject).to normalize(:attribute_name).from("parent_id").to("parent")+ end+ end+describe "instance" dosubject { build(:project_help_text) }diff --git a/spec/models/attribute_help_text/work_package_spec.rb b/spec/models/attribute_help_text/work_package_spec.rbindex a3fd96fccaf..c491c3ad8d7 100644--- a/spec/models/attribute_help_text/work_package_spec.rb+++ b/spec/models/attribute_help_text/work_package_spec.rb@@ -197,6 +197,14 @@ RSpec.describe AttributeHelpText::WorkPackage doendend+ describe "normalization" do+ it "normalizes attribute_name" do+ expect(subject).to normalize(:attribute_name).from("category_id").to("category")+ expect(subject).to normalize(:attribute_name).from("status_id").to("status")+ expect(subject).to normalize(:attribute_name).from("author_id").to("author")+ end+ end+describe "instance" dosubject { build(:work_package_help_text) }