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

Fix single PDF export spec

Oliver Günthere5702639c38f
diff --git a/spec/controllers/work_packages_controller_spec.rb b/spec/controllers/work_packages_controller_spec.rb
index 9addb462280..81ad093eb0b 100644
--- a/spec/controllers/work_packages_controller_spec.rb
+++ b/spec/controllers/work_packages_controller_spec.rb
@@ -205,8 +205,7 @@ describe WorkPackagesController, type: :controller do
let(:params) { {} }
let(:mime_type) { 'pdf' }
- it_behaves_like 'export of mime_type' do
- end
+ it_behaves_like 'export of mime_type'
end
describe 'atom' do
@@ -280,6 +279,12 @@ describe WorkPackagesController, type: :controller do
describe 'show.pdf' do
let(:call_action) { get('show', params: { format: 'pdf', id: '1337' }) }
+ let(:exporter) { WorkPackage::PDFExport::WorkPackageToPdf }
+ let(:exporter_instance) { instance_double(exporter) }
+
+ before do
+ allow(exporter).to receive(:new).and_return(exporter_instance)
+ end
requires_permission_in_project do
it 'respond with a pdf' do
@@ -292,7 +297,7 @@ describe WorkPackagesController, type: :controller do
title: expected_name,
mime_type: expected_type)
- expect(WorkPackage::Exporter::PDF).to receive(:single).and_yield(pdf_result)
+ allow(exporter_instance).to receive(:export!).and_yield(pdf_result)
expect(controller).to receive(:send_data).with(pdf_data,
type: expected_type,
filename: expected_name) do |*_args|