From b38a1fb63f22103ef68adbf868f88263e8c9d037 Mon Sep 17 00:00:00 2001 From: as-op Date: Wed, 26 Jul 2023 16:51:42 +0200 Subject: [PATCH] add formatting. mention and image attachment to description --- .../pdf_export/work_package_to_pdf_spec.rb | 54 +++++++++++++------ 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb b/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb index 1447a4a688cd..aeb478464c98 100644 --- a/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb +++ b/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb @@ -40,13 +40,33 @@ end let(:export_time) { DateTime.new(2023, 6, 30, 23, 59) } let(:export_time_formatted) { format_time(export_time, true) } + let(:image_path) { Rails.root.join("spec/fixtures/files/image.png") } + let(:image_attachment) { Attachment.new author: user, file: File.open(image_path) } + let(:attachments) { [image_attachment] } let(:work_package) do + description = <<~DESCRIPTION + **Lorem** _ipsum_ ~~dolor~~ `sit` [amet](https://example.com/), consetetur sadipscing elitr. + @OpenProject Admin + ![](/api/v3/attachments/#{image_attachment.id}/content) +

+

+
+ "foobar" +
+
Image Caption
+
+

+ DESCRIPTION create(:work_package, - project:, - type:, - subject: 'Work package 1', - story_points: 1, - description: 'This is a description') + project:, + type:, + subject: 'Work package 1', + story_points: 1, + description:).tap do |wp| + allow(wp) + .to receive(:attachments) + .and_return attachments + end end let(:options) { {} } let(:export) do @@ -68,19 +88,21 @@ expect(pdf.strings).to eq([ "#{type.name} ##{work_package.id} - #{work_package.subject}", 'ID', work_package.id.to_s, - "UPDATED ON", export_time_formatted, - "TYPE", type.name, - "CREATED ON", export_time_formatted, + 'UPDATED ON', export_time_formatted, + 'TYPE', type.name, + 'CREATED ON', export_time_formatted, 'STATUS', work_package.status.name, - "FINISH DATE", - "VERSION", - "PRIORITY", work_package.priority.name, - "DURATION", - "WORK", - "CATEGORY", - "ASSIGNEE", + 'FINISH DATE', + 'VERSION', + 'PRIORITY', work_package.priority.name, + 'DURATION', + 'WORK', + 'CATEGORY', + 'ASSIGNEE', 'Description', - work_package.description, + 'Lorem', ' ', 'ipsum', ' ', 'dolor', ' ', 'sit', ' ', + 'amet', ', consetetur sadipscing elitr.', ' ', '@OpenProject Admin', + 'Image Caption', '1', export_time_formatted, project.name ]) end