diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-19 14:01:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-19 14:01:45 +0300 |
commit | 9297025d0b7ddf095eb618dfaaab2ff8f2018d8b (patch) | |
tree | 865198c01d1824a9b098127baa3ab980c9cd2c06 /spec/lib/gitlab/pages/deployment_update_spec.rb | |
parent | 6372471f43ee03c05a7c1f8b0c6ac6b8a7431dbe (diff) |
Add latest changes from gitlab-org/gitlab@16-7-stable-eev16.7.0-rc42
Diffstat (limited to 'spec/lib/gitlab/pages/deployment_update_spec.rb')
-rw-r--r-- | spec/lib/gitlab/pages/deployment_update_spec.rb | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/spec/lib/gitlab/pages/deployment_update_spec.rb b/spec/lib/gitlab/pages/deployment_update_spec.rb index 9a7564ddd59..48f5b27b761 100644 --- a/spec/lib/gitlab/pages/deployment_update_spec.rb +++ b/spec/lib/gitlab/pages/deployment_update_spec.rb @@ -5,8 +5,8 @@ require 'spec_helper' RSpec.describe Gitlab::Pages::DeploymentUpdate, feature_category: :pages do let_it_be(:project, refind: true) { create(:project, :repository) } - let_it_be(:old_pipeline) { create(:ci_pipeline, project: project, sha: project.commit('HEAD').sha) } - let_it_be(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit('HEAD').sha) } + let_it_be(:old_pipeline) { create(:ci_pipeline, project: project, sha: project.commit('HEAD~~').sha) } + let_it_be(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit('HEAD~').sha) } let(:build) { create(:ci_build, pipeline: pipeline, ref: 'HEAD') } let(:invalid_file) { fixture_file_upload('spec/fixtures/dk.png') } @@ -137,4 +137,35 @@ RSpec.describe Gitlab::Pages::DeploymentUpdate, feature_category: :pages do expect(pages_deployment_update).to be_valid end end + + context 'when validating if current build is outdated' do + before do + create(:ci_job_artifact, :correct_checksum, file: file, job: build) + create(:ci_job_artifact, file_type: :metadata, file_format: :gzip, file: metadata, job: build) + build.reload + end + + context 'when there is NOT a newer build' do + it 'does not fail' do + expect(pages_deployment_update).to be_valid + end + end + + context 'when there is a newer build' do + before do + new_pipeline = create(:ci_pipeline, project: project, sha: project.commit('HEAD').sha) + new_build = create(:ci_build, name: 'pages', pipeline: new_pipeline, ref: 'HEAD') + create(:ci_job_artifact, :correct_checksum, file: file, job: new_build) + create(:ci_job_artifact, file_type: :metadata, file_format: :gzip, file: metadata, job: new_build) + create(:pages_deployment, project: project, ci_build: new_build) + new_build.reload + end + + it 'fails with outdated reference message' do + expect(pages_deployment_update).not_to be_valid + expect(pages_deployment_update.errors.full_messages) + .to include('build SHA is outdated for this ref') + end + end + end end |