From 5da2f42dc9609c07fd60d9d1c7a2302353a820c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Wed, 7 Nov 2018 16:54:37 +0100 Subject: backport: Always proxy reports downloads This makes to always proxy reports --- spec/controllers/concerns/send_file_upload_spec.rb | 29 +++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'spec/controllers/concerns') diff --git a/spec/controllers/concerns/send_file_upload_spec.rb b/spec/controllers/concerns/send_file_upload_spec.rb index 767fba7fd58..4f1f6bb31f3 100644 --- a/spec/controllers/concerns/send_file_upload_spec.rb +++ b/spec/controllers/concerns/send_file_upload_spec.rb @@ -28,8 +28,9 @@ describe SendFileUpload do describe '#send_upload' do let(:controller) { controller_class.new } let(:temp_file) { Tempfile.new('test') } + let(:params) { {} } - subject { controller.send_upload(uploader) } + subject { controller.send_upload(uploader, **params) } before do FileUtils.touch(temp_file) @@ -52,7 +53,7 @@ describe SendFileUpload do end context 'with attachment' do - let(:send_attachment) { controller.send_upload(uploader, attachment: 'test.js') } + let(:params) { { attachment: 'test.js' } } it 'sends a file with content-type of text/plain' do expected_params = { @@ -62,7 +63,7 @@ describe SendFileUpload do } expect(controller).to receive(:send_file).with(uploader.path, expected_params) - send_attachment + subject end context 'with a proxied file in object storage' do @@ -83,7 +84,7 @@ describe SendFileUpload do expect(controller).to receive(:headers) { headers } expect(controller).to receive(:head).with(:ok) - send_attachment + subject end end end @@ -95,11 +96,7 @@ describe SendFileUpload do uploader.store!(temp_file) end - context 'and proxying is enabled' do - before do - allow(Gitlab.config.uploads.object_store).to receive(:proxy_download) { true } - end - + shared_examples 'proxied file' do it 'sends a file' do headers = double expect(Gitlab::Workhorse).not_to receive(:send_url).with(/response-content-disposition/) @@ -115,6 +112,14 @@ describe SendFileUpload do end end + context 'and proxying is enabled' do + before do + allow(Gitlab.config.uploads.object_store).to receive(:proxy_download) { true } + end + + it_behaves_like 'proxied file' + end + context 'and proxying is disabled' do before do allow(Gitlab.config.uploads.object_store).to receive(:proxy_download) { false } @@ -125,6 +130,12 @@ describe SendFileUpload do subject end + + context 'with proxy requested' do + let(:params) { { proxy: true } } + + it_behaves_like 'proxied file' + end end end end -- cgit v1.2.3