Commit a792ea39 authored by Erick Bajao's avatar Erick Bajao

Use has_expiring_archive_artifacts in BuildArtifactEntity

Move has_expiring_artifacts to be private.
parent c92043c5
...@@ -717,10 +717,6 @@ module Ci ...@@ -717,10 +717,6 @@ module Ci
end end
end end
def has_expiring_artifacts?
artifacts_expire_at.present? && artifacts_expire_at > Time.now
end
def has_expiring_archive_artifacts? def has_expiring_archive_artifacts?
has_expiring_artifacts? && artifacts_file&.exists? has_expiring_artifacts? && artifacts_file&.exists?
end end
...@@ -929,6 +925,10 @@ module Ci ...@@ -929,6 +925,10 @@ 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_artifacts? } do |job| expose :keep_path, if: -> (*) { job.has_expiring_archive_artifacts? } do |job|
keep_project_job_artifacts_path(project, job) keep_project_job_artifacts_path(project, job)
end end
......
...@@ -2224,28 +2224,6 @@ describe Ci::Build do ...@@ -2224,28 +2224,6 @@ describe Ci::Build do
end end
end end
describe '#has_expiring_artifacts?' do
context 'when artifacts have expiration date set' do
before do
build.update(artifacts_expire_at: 1.day.from_now)
end
it 'has expiring artifacts' do
expect(build).to have_expiring_artifacts
end
end
context 'when artifacts do not have expiration date set' do
before do
build.update(artifacts_expire_at: nil)
end
it 'does not have expiring artifacts' do
expect(build).not_to have_expiring_artifacts
end
end
end
describe '#has_expiring_archive_artifacts?' do describe '#has_expiring_archive_artifacts?' do
context 'when artifacts have expiration date set' do context 'when artifacts have expiration date set' do
before do before do
......
...@@ -4,6 +4,8 @@ require 'spec_helper' ...@@ -4,6 +4,8 @@ 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)
......
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