diff options
Diffstat (limited to 'spec/presenters/ci/build_runner_presenter_spec.rb')
-rw-r--r-- | spec/presenters/ci/build_runner_presenter_spec.rb | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/spec/presenters/ci/build_runner_presenter_spec.rb b/spec/presenters/ci/build_runner_presenter_spec.rb index ce4c5a2db7d..f78ad38f4e8 100644 --- a/spec/presenters/ci/build_runner_presenter_spec.rb +++ b/spec/presenters/ci/build_runner_presenter_spec.rb @@ -189,7 +189,21 @@ RSpec.describe Ci::BuildRunnerPresenter do it 'returns the correct refspecs' do is_expected.to contain_exactly("+refs/heads/#{build.ref}:refs/remotes/origin/#{build.ref}", - "+refs/pipelines/#{pipeline.id}:refs/pipelines/#{pipeline.id}") + "+#{pipeline.sha}:refs/pipelines/#{pipeline.id}") + end + + it 'uses a SHA in the persistent refspec' do + expect(subject[0]).to match(/^\+[0-9a-f]{40}:refs\/pipelines\/[0-9]+$/) + end + + context 'when the scalability_ci_fetch_sha feature flag is disabled' do + before do + stub_feature_flags(scalability_ci_fetch_sha: false) + end + + it 'fetches the ref by name' do + expect(subject[0]).to eq("+refs/pipelines/#{pipeline.id}:refs/pipelines/#{pipeline.id}") + end end context 'when ref is tag' do @@ -197,7 +211,7 @@ RSpec.describe Ci::BuildRunnerPresenter do it 'returns the correct refspecs' do is_expected.to contain_exactly("+refs/tags/#{build.ref}:refs/tags/#{build.ref}", - "+refs/pipelines/#{pipeline.id}:refs/pipelines/#{pipeline.id}") + "+#{pipeline.sha}:refs/pipelines/#{pipeline.id}") end context 'when GIT_DEPTH is zero' do @@ -208,7 +222,7 @@ RSpec.describe Ci::BuildRunnerPresenter do it 'returns the correct refspecs' do is_expected.to contain_exactly('+refs/tags/*:refs/tags/*', '+refs/heads/*:refs/remotes/origin/*', - "+refs/pipelines/#{pipeline.id}:refs/pipelines/#{pipeline.id}") + "+#{pipeline.sha}:refs/pipelines/#{pipeline.id}") end end end @@ -224,7 +238,7 @@ RSpec.describe Ci::BuildRunnerPresenter do it 'returns the correct refspecs' do is_expected - .to contain_exactly("+refs/pipelines/#{pipeline.id}:refs/pipelines/#{pipeline.id}") + .to contain_exactly("+#{pipeline.sha}:refs/pipelines/#{pipeline.id}") end context 'when GIT_DEPTH is zero' do @@ -234,7 +248,7 @@ RSpec.describe Ci::BuildRunnerPresenter do it 'returns the correct refspecs' do is_expected - .to contain_exactly("+refs/pipelines/#{pipeline.id}:refs/pipelines/#{pipeline.id}", + .to contain_exactly("+#{pipeline.sha}:refs/pipelines/#{pipeline.id}", '+refs/heads/*:refs/remotes/origin/*', '+refs/tags/*:refs/tags/*') end @@ -244,7 +258,7 @@ RSpec.describe Ci::BuildRunnerPresenter do let(:merge_request) { create(:merge_request, :with_legacy_detached_merge_request_pipeline) } it 'returns the correct refspecs' do - is_expected.to contain_exactly("+refs/pipelines/#{pipeline.id}:refs/pipelines/#{pipeline.id}", + is_expected.to contain_exactly("+#{pipeline.sha}:refs/pipelines/#{pipeline.id}", "+refs/heads/#{build.ref}:refs/remotes/origin/#{build.ref}") end end @@ -262,7 +276,7 @@ RSpec.describe Ci::BuildRunnerPresenter do it 'exposes the persistent pipeline ref' do is_expected - .to contain_exactly("+refs/pipelines/#{pipeline.id}:refs/pipelines/#{pipeline.id}", + .to contain_exactly("+#{pipeline.sha}:refs/pipelines/#{pipeline.id}", "+refs/heads/#{build.ref}:refs/remotes/origin/#{build.ref}") end end |