Merge branch 'fix/sm/clarify-ambiguous-with_artifacts-implication' into 'master'
Clarify ambiguous with_artifacts implication Closes #44138 See merge request gitlab-org/gitlab-ce!17720
This commit is contained in:
commit
5778de6720
|
@ -41,12 +41,12 @@ module Ci
|
|||
|
||||
scope :unstarted, ->() { where(runner_id: nil) }
|
||||
scope :ignore_failures, ->() { where(allow_failure: false) }
|
||||
scope :with_artifacts, ->() do
|
||||
scope :with_artifacts_archive, ->() do
|
||||
where('(artifacts_file IS NOT NULL AND artifacts_file <> ?) OR EXISTS (?)',
|
||||
'', Ci::JobArtifact.select(1).where('ci_builds.id = ci_job_artifacts.job_id'))
|
||||
'', Ci::JobArtifact.select(1).where('ci_builds.id = ci_job_artifacts.job_id').archive)
|
||||
end
|
||||
scope :with_artifacts_not_expired, ->() { with_artifacts.where('artifacts_expire_at IS NULL OR artifacts_expire_at > ?', Time.now) }
|
||||
scope :with_expired_artifacts, ->() { with_artifacts.where('artifacts_expire_at < ?', Time.now) }
|
||||
scope :with_artifacts_not_expired, ->() { with_artifacts_archive.where('artifacts_expire_at IS NULL OR artifacts_expire_at > ?', Time.now) }
|
||||
scope :with_expired_artifacts, ->() { with_artifacts_archive.where('artifacts_expire_at < ?', Time.now) }
|
||||
scope :last_month, ->() { where('created_at > ?', Date.today - 1.month) }
|
||||
scope :manual_actions, ->() { where(when: :manual, status: COMPLETED_STATUSES + [:manual]) }
|
||||
scope :ref_protected, -> { where(protected: true) }
|
||||
|
|
|
@ -513,7 +513,7 @@ module Ci
|
|||
# We purposely cast the builds to an Array here. Because we always use the
|
||||
# rows if there are more than 0 this prevents us from having to run two
|
||||
# queries: one to get the count and one to get the rows.
|
||||
@latest_builds_with_artifacts ||= builds.latest.with_artifacts.to_a
|
||||
@latest_builds_with_artifacts ||= builds.latest.with_artifacts_archive.to_a
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -542,7 +542,7 @@ class Project < ActiveRecord::Base
|
|||
latest_pipeline = pipelines.latest_successful_for(ref)
|
||||
|
||||
if latest_pipeline
|
||||
latest_pipeline.builds.latest.with_artifacts
|
||||
latest_pipeline.builds.latest.with_artifacts_archive
|
||||
else
|
||||
builds.none
|
||||
end
|
||||
|
|
|
@ -349,6 +349,18 @@ describe 'Pipelines', :js do
|
|||
|
||||
it { expect(page).not_to have_selector('.build-artifacts') }
|
||||
end
|
||||
|
||||
context 'with trace artifact' do
|
||||
before do
|
||||
create(:ci_build, :success, :trace_artifact, pipeline: pipeline)
|
||||
|
||||
visit_project_pipelines
|
||||
end
|
||||
|
||||
it 'does not show trace artifact as artifacts' do
|
||||
expect(page).not_to have_selector('.build-artifacts')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'mini pipeline graph' do
|
||||
|
|
|
@ -66,7 +66,7 @@ describe MigrateOldArtifacts do
|
|||
end
|
||||
|
||||
it 'all files do have artifacts' do
|
||||
Ci::Build.with_artifacts do |build|
|
||||
Ci::Build.with_artifacts_archive do |build|
|
||||
expect(build).to have_artifacts
|
||||
end
|
||||
end
|
||||
|
|
|
@ -80,6 +80,42 @@ describe Ci::Build do
|
|||
end
|
||||
end
|
||||
|
||||
describe '.with_artifacts_archive' do
|
||||
subject { described_class.with_artifacts_archive }
|
||||
|
||||
context 'when job does not have an archive' do
|
||||
let!(:job) { create(:ci_build) }
|
||||
|
||||
it 'does not return the job' do
|
||||
is_expected.not_to include(job)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when job has a legacy archive' do
|
||||
let!(:job) { create(:ci_build, :legacy_artifacts) }
|
||||
|
||||
it 'returns the job' do
|
||||
is_expected.to include(job)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when job has a job artifact archive' do
|
||||
let!(:job) { create(:ci_build, :artifacts) }
|
||||
|
||||
it 'returns the job' do
|
||||
is_expected.to include(job)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when job has a job artifact trace' do
|
||||
let!(:job) { create(:ci_build, :trace_artifact) }
|
||||
|
||||
it 'does not return the job' do
|
||||
is_expected.not_to include(job)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#actionize' do
|
||||
context 'when build is a created' do
|
||||
before do
|
||||
|
|
Loading…
Reference in New Issue