Commit fcd1e422 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'revert-c0d1383c' into 'master'

Revert "Merge branch 'eb-no-keep-report-artifacts' into 'master'"

Closes #121663

See merge request gitlab-org/gitlab!22225
parents 77c7ba10 aef12ce5
...@@ -719,8 +719,8 @@ module Ci ...@@ -719,8 +719,8 @@ module Ci
end end
end end
def has_expiring_archive_artifacts? def has_expiring_artifacts?
has_expiring_artifacts? && artifacts_file&.exists? artifacts_expire_at.present? && artifacts_expire_at > Time.now
end end
def keep_artifacts! def keep_artifacts!
...@@ -935,10 +935,6 @@ module Ci ...@@ -935,10 +935,6 @@ module Ci
value.with_indifferent_access value.with_indifferent_access
end end
end end
def has_expiring_artifacts?
artifacts_expire_at.present? && artifacts_expire_at > Time.now
end
end end
end end
......
...@@ -14,7 +14,7 @@ class BuildArtifactEntity < Grape::Entity ...@@ -14,7 +14,7 @@ class BuildArtifactEntity < Grape::Entity
download_project_job_artifacts_path(project, job) download_project_job_artifacts_path(project, job)
end end
expose :keep_path, if: -> (*) { job.has_expiring_archive_artifacts? } do |job| expose :keep_path, if: -> (*) { job.has_expiring_artifacts? } do |job|
keep_project_job_artifacts_path(project, job) keep_project_job_artifacts_path(project, job)
end end
......
...@@ -31,7 +31,7 @@ class BuildDetailsEntity < JobEntity ...@@ -31,7 +31,7 @@ class BuildDetailsEntity < JobEntity
browse_project_job_artifacts_path(project, build) browse_project_job_artifacts_path(project, build)
end end
expose :keep_path, if: -> (*) { build.has_expiring_archive_artifacts? && can?(current_user, :update_build, build) } do |build| expose :keep_path, if: -> (*) { build.has_expiring_artifacts? && can?(current_user, :update_build, build) } do |build|
keep_project_job_artifacts_path(project, build) keep_project_job_artifacts_path(project, build)
end end
......
---
title: Remove keep button for non archive artifacts
merge_request: 21553
author:
type: fixed
...@@ -2248,24 +2248,14 @@ describe Ci::Build do ...@@ -2248,24 +2248,14 @@ describe Ci::Build do
end end
end end
describe '#has_expiring_archive_artifacts?' do describe '#has_expiring_artifacts?' do
context 'when artifacts have expiration date set' do context 'when artifacts have expiration date set' do
before do before do
build.update(artifacts_expire_at: 1.day.from_now) build.update(artifacts_expire_at: 1.day.from_now)
end end
context 'and job artifacts file exists' do it 'has expiring artifacts' do
let!(:archive) { create(:ci_job_artifact, :archive, job: build) } expect(build).to have_expiring_artifacts
it 'has expiring artifacts' do
expect(build).to have_expiring_archive_artifacts
end
end
context 'and job artifacts file does not exist' do
it 'does not have expiring artifacts' do
expect(build).not_to have_expiring_archive_artifacts
end
end end
end end
...@@ -2275,7 +2265,7 @@ describe Ci::Build do ...@@ -2275,7 +2265,7 @@ describe Ci::Build do
end end
it 'does not have expiring artifacts' do it 'does not have expiring artifacts' do
expect(build).not_to have_expiring_archive_artifacts expect(build).not_to have_expiring_artifacts
end end
end end
end end
......
...@@ -4,8 +4,6 @@ require 'spec_helper' ...@@ -4,8 +4,6 @@ require 'spec_helper'
describe BuildArtifactEntity do describe BuildArtifactEntity do
let(:job) { create(:ci_build, name: 'test:job', artifacts_expire_at: 1.hour.from_now) } let(:job) { create(:ci_build, name: 'test:job', artifacts_expire_at: 1.hour.from_now) }
let!(:archive) { create(:ci_job_artifact, :archive, job: job) }
let!(:metadata) { create(:ci_job_artifact, :metadata, job: job) }
let(:entity) do let(:entity) do
described_class.new(job, request: double) described_class.new(job, request: double)
......
...@@ -176,27 +176,5 @@ describe BuildDetailsEntity do ...@@ -176,27 +176,5 @@ describe BuildDetailsEntity do
expect(subject[:reports].first[:file_type]).to eq('codequality') expect(subject[:reports].first[:file_type]).to eq('codequality')
end end
end end
context 'when the build has no archive type artifacts' do
let!(:report) { create(:ci_job_artifact, :codequality, job: build) }
it 'does not expose any artifact actions path' do
expect(subject[:artifact].keys).not_to include(:download_path, :browse_path, :keep_path)
end
end
context 'when the build has archive type artifacts' do
let!(:report) { create(:ci_job_artifact, :codequality, job: build) }
let!(:archive) { create(:ci_job_artifact, :archive, job: build) }
let!(:metadata) { create(:ci_job_artifact, :metadata, job: build) }
before do
build.update(artifacts_expire_at: 7.days.from_now)
end
it 'exposes artifact details' do
expect(subject[:artifact].keys).to include(:download_path, :browse_path, :keep_path, :expire_at, :expired)
end
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment