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

test(pdf-export): add test for long filename truncation

as-op2ec26ab6ba4a
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 5af29f73361..61e7995e703 100644
--- a/spec/workers/work_packages/exports/export_job_integration_spec.rb
+++ b/spec/workers/work_packages/exports/export_job_integration_spec.rb
@@ -79,4 +79,21 @@ RSpec.describe WorkPackages::ExportJob, 'Integration' do
expect(attachment.filename).to eq expected
end
end
+
+ describe 'with overly long project title' do
+ let(:project) { create(:project, name: "x" * 255) }
+
+ it 'exports the job correctly, limiting the result file length' do
+ time = DateTime.new(2023, 6, 30, 23, 59)
+ allow(DateTime).to receive(:now).and_return(time)
+
+ expect { performed_job }.not_to raise_error
+
+ expect(job_status.status).to eq 'success'
+
+ attachment = export.attachments.last
+ expect(attachment.filename.chars.length).to eq 255
+ expect(attachment.filename).to end_with "_2023-06-30_23-59.pdf"
+ end
+ end
end