Skip to content

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

remove rescue I18n::MissingTranslationData as it's thrown in dev & test; but disable it for the tests it would be thrown

as-opc1c7dc127f8e
diff --git a/app/models/work_package/exports/macros/attributes.rb b/app/models/work_package/exports/macros/attributes.rb
index 32be596fdd3..8c73907f0f4 100644
--- a/app/models/work_package/exports/macros/attributes.rb
+++ b/app/models/work_package/exports/macros/attributes.rb
@@ -105,10 +105,6 @@ module WorkPackage::Exports
model.human_attribute_name(
::API::Utilities::PropertyNameConverter.to_ar_name(attribute.to_sym, context: model.new)
)
- rescue I18n::MissingTranslationData
- # If the translation is missing, we return the attribute name as a fallback
- # # This can happen if the attribute is a custom field, the attribute is not translated or does not exist
- attribute.to_s
end
def self.resolve_work_package_match(id, type, attribute, user)
diff --git a/spec/models/work_package/pdf_export/common/macro_spec.rb b/spec/models/work_package/pdf_export/common/macro_spec.rb
index a96e151730d..a6b1c7543b2 100644
--- a/spec/models/work_package/pdf_export/common/macro_spec.rb
+++ b/spec/models/work_package/pdf_export/common/macro_spec.rb
@@ -252,6 +252,16 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro do
end
describe "workPackageLabel macro" do
+ let!(:original_setting) { ActiveModel::Translation.raise_on_missing_translations }
+
+ before do
+ ActiveModel::Translation.raise_on_missing_translations = false
+ end
+
+ after do
+ ActiveModel::Translation.raise_on_missing_translations = original_setting
+ end
+
describe "with current work package attribute" do
let(:markdown) { "workPackageLabel:subject" }
@@ -288,7 +298,7 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro do
let(:markdown) { "workPackageLabel:\"Custom Field 1\"" }
it "outputs the custom field name" do
- expect(formatted).to eq("Custom Field 1")
+ expect(formatted).to eq("Custom field 1")
end
end
@@ -296,7 +306,7 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro do
let(:markdown) { "workPackageLabel:185:\"Custom Field 1\"" }
it "outputs the custom field name for the specified work package" do
- expect(formatted).to eq("Custom Field 1")
+ expect(formatted).to eq("Custom field 1")
end
end
@@ -304,7 +314,7 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro do
let(:markdown) { "workPackageLabel:nonexistent_attribute" }
it "outputs the humanized attribute name" do
- expect(formatted).to eq("nonexistent_attribute")
+ expect(formatted).to eq("Nonexistent attribute")
end
end
@@ -408,6 +418,16 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro do
end
describe "projectLabel macro" do
+ let!(:original_setting) { ActiveModel::Translation.raise_on_missing_translations }
+
+ before do
+ ActiveModel::Translation.raise_on_missing_translations = false
+ end
+
+ after do
+ ActiveModel::Translation.raise_on_missing_translations = original_setting
+ end
+
describe "with current project attribute" do
let(:markdown) { "projectLabel:name" }
@@ -452,7 +472,7 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro do
let(:markdown) { "projectLabel:\"Project Custom Field 1\"" }
it "outputs the custom field name" do
- expect(formatted).to eq("Project Custom Field 1")
+ expect(formatted).to eq("Project custom field 1")
end
end
@@ -460,7 +480,7 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro do
let(:markdown) { "projectLabel:#{project.id}:\"Project Custom Field 1\"" }
it "outputs the custom field name for the specified project" do
- expect(formatted).to eq("Project Custom Field 1")
+ expect(formatted).to eq("Project custom field 1")
end
end
@@ -468,7 +488,7 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro do
let(:markdown) { "projectLabel:nonexistent_attribute" }
it "outputs the humanized attribute name" do
- expect(formatted).to eq("nonexistent_attribute")
+ expect(formatted).to eq("Nonexistent attribute")
end
end