diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /spec/lib/api/helpers_spec.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'spec/lib/api/helpers_spec.rb')
-rw-r--r-- | spec/lib/api/helpers_spec.rb | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/spec/lib/api/helpers_spec.rb b/spec/lib/api/helpers_spec.rb index d24a3bd13c0..a0f5ee1ea95 100644 --- a/spec/lib/api/helpers_spec.rb +++ b/spec/lib/api/helpers_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe API::Helpers do +RSpec.describe API::Helpers, feature_category: :not_owned do using RSpec::Parameterized::TableSyntax subject(:helper) { Class.new.include(described_class).new } @@ -11,7 +11,7 @@ RSpec.describe API::Helpers do include Rack::Test::Methods let(:user) { build(:user, id: 42) } - + let(:request) { instance_double(Rack::Request) } let(:helper) do Class.new(Grape::API::Instance) do helpers API::APIGuard::HelperMethods @@ -797,12 +797,13 @@ RSpec.describe API::Helpers do describe '#present_artifacts_file!' do context 'with object storage' do let(:artifact) { create(:ci_job_artifact, :zip, :remote_store) } + let(:is_head_request) { false } subject { helper.present_artifacts_file!(artifact.file) } before do allow(helper).to receive(:env).and_return({}) - + allow(helper).to receive(:request).and_return(instance_double(Rack::Request, head?: is_head_request)) stub_artifacts_object_storage(enabled: true) end @@ -814,6 +815,18 @@ RSpec.describe API::Helpers do subject end + + context 'requested with HEAD' do + let(:is_head_request) { true } + + it 'redirects to a CDN-fronted URL' do + expect(helper).to receive(:redirect) + expect(helper).to receive(:signed_head_url).and_call_original + expect(Gitlab::ApplicationContext).to receive(:push).with(artifact: artifact.file.model).and_call_original + + subject + end + end end end |