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

Fixes Performance/RedundantStringChars offenses

Klaus Zanders00b3de8dc5c4
diff --git a/app/models/work_package/pdf_export/common.rb b/app/models/work_package/pdf_export/common.rb
index 7a2a4305a73..a5d8baf7c67 100644
--- a/app/models/work_package/pdf_export/common.rb
+++ b/app/models/work_package/pdf_export/common.rb
@@ -299,7 +299,7 @@ module WorkPackage::PDFExport::Common
def build_pdf_filename(base)
suffix = "_#{title_datetime}.pdf"
- "#{truncate(base, length: 255 - suffix.chars.length)}#{suffix}".gsub(' ', '-')
+ "#{truncate(base, length: 255 - suffix.length)}#{suffix}".gsub(' ', '-')
end
def title_datetime
diff --git a/spec/workers/work_packages/exports/export_job_integration_spec.rb b/spec/workers/work_packages/exports/export_job_integration_spec.rb
index 61e7995e703..70b885b288d 100644
--- a/spec/workers/work_packages/exports/export_job_integration_spec.rb
+++ b/spec/workers/work_packages/exports/export_job_integration_spec.rb
@@ -92,7 +92,7 @@ RSpec.describe WorkPackages::ExportJob, 'Integration' do
expect(job_status.status).to eq 'success'
attachment = export.attachments.last
- expect(attachment.filename.chars.length).to eq 255
+ expect(attachment.filename.length).to eq 255
expect(attachment.filename).to end_with "_2023-06-30_23-59.pdf"
end
end