Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers/concerns/send_file_upload_spec.rb')
-rw-r--r--spec/controllers/concerns/send_file_upload_spec.rb15
1 files changed, 9 insertions, 6 deletions
diff --git a/spec/controllers/concerns/send_file_upload_spec.rb b/spec/controllers/concerns/send_file_upload_spec.rb
index 0b24387483b..6acbff6e745 100644
--- a/spec/controllers/concerns/send_file_upload_spec.rb
+++ b/spec/controllers/concerns/send_file_upload_spec.rb
@@ -54,17 +54,18 @@ RSpec.describe SendFileUpload do
FileUtils.rm_f(temp_file)
end
- shared_examples 'handles image resize requests' do
+ shared_examples 'handles image resize requests' do |mount|
let(:headers) { double }
let(:image_requester) { build(:user) }
let(:image_owner) { build(:user) }
+ let(:width) { mount == :pwa_icon ? 192 : 64 }
let(:params) do
{ attachment: 'avatar.png' }
end
before do
allow(uploader).to receive(:image_safe_for_scaling?).and_return(true)
- allow(uploader).to receive(:mounted_as).and_return(:avatar)
+ allow(uploader).to receive(:mounted_as).and_return(mount)
allow(controller).to receive(:headers).and_return(headers)
# both of these are valid cases, depending on whether we are dealing with
@@ -99,11 +100,11 @@ RSpec.describe SendFileUpload do
context 'with valid width parameter' do
it 'renders OK with workhorse command header' do
expect(controller).not_to receive(:send_file)
- expect(controller).to receive(:params).at_least(:once).and_return(width: '64')
+ expect(controller).to receive(:params).at_least(:once).and_return(width: width.to_s)
expect(controller).to receive(:head).with(:ok)
expect(Gitlab::Workhorse).to receive(:send_scaled_image)
- .with(a_string_matching('^(/.+|https://.+)'), 64, 'image/png')
+ .with(a_string_matching('^(/.+|https://.+)'), width, 'image/png')
.and_return([Gitlab::Workhorse::SEND_DATA_HEADER, "send-scaled-img:faux"])
expect(headers).to receive(:store).with(Gitlab::Workhorse::SEND_DATA_HEADER, "send-scaled-img:faux")
@@ -168,7 +169,8 @@ RSpec.describe SendFileUpload do
subject
end
- it_behaves_like 'handles image resize requests'
+ it_behaves_like 'handles image resize requests', :avatar
+ it_behaves_like 'handles image resize requests', :pwa_icon
end
context 'with inline image' do
@@ -273,7 +275,8 @@ RSpec.describe SendFileUpload do
end
end
- it_behaves_like 'handles image resize requests'
+ it_behaves_like 'handles image resize requests', :avatar
+ it_behaves_like 'handles image resize requests', :pwa_icon
end
context 'when CDN-enabled remote file is used' do