Commit 5d0537bb authored by Matija Čupić's avatar Matija Čupić

Check for artifact locking in artifact_*? methods

parent 8a13ab76
...@@ -777,6 +777,8 @@ module Ci ...@@ -777,6 +777,8 @@ module Ci
end end
def artifacts_expired? def artifacts_expired?
return false if artifacts_locked?
artifacts_expire_at && artifacts_expire_at < Time.current artifacts_expire_at && artifacts_expire_at < Time.current
end end
...@@ -958,6 +960,10 @@ module Ci ...@@ -958,6 +960,10 @@ module Ci
private private
def artifacts_locked?
job_artifacts_archive&.locked?
end
def dependencies def dependencies
strong_memoize(:dependencies) do strong_memoize(:dependencies) do
Ci::BuildDependencies.new(self) Ci::BuildDependencies.new(self)
...@@ -1027,6 +1033,8 @@ module Ci ...@@ -1027,6 +1033,8 @@ module Ci
end end
def has_expiring_artifacts? def has_expiring_artifacts?
return false if artifacts_locked?
artifacts_expire_at.present? && artifacts_expire_at > Time.current artifacts_expire_at.present? && artifacts_expire_at > Time.current
end end
......
...@@ -590,7 +590,6 @@ describe Ci::Build do ...@@ -590,7 +590,6 @@ describe Ci::Build do
describe '#artifacts?' do describe '#artifacts?' do
subject { build.artifacts? } subject { build.artifacts? }
context 'when new artifacts are used' do
context 'artifacts archive does not exist' do context 'artifacts archive does not exist' do
let(:build) { create(:ci_build) } let(:build) { create(:ci_build) }
...@@ -606,6 +605,13 @@ describe Ci::Build do ...@@ -606,6 +605,13 @@ describe Ci::Build do
let(:build) { create(:ci_build, :artifacts, :expired) } let(:build) { create(:ci_build, :artifacts, :expired) }
it { is_expected.to be_falsy } it { is_expected.to be_falsy }
context 'is locked' do
before do
build.job_artifacts_archive.update(locked: true)
end
it { is_expected.to be_truthy }
end end
end end
end end
...@@ -630,6 +636,14 @@ describe Ci::Build do ...@@ -630,6 +636,14 @@ describe Ci::Build do
end end
it { is_expected.to be_truthy } it { is_expected.to be_truthy }
context 'is locked' do
before do
create(:ci_job_artifact, :archive, job: build, locked: true)
end
it { is_expected.to be_falsey }
end
end end
context 'is not expired' do context 'is not expired' do
...@@ -2252,6 +2266,16 @@ describe Ci::Build do ...@@ -2252,6 +2266,16 @@ describe Ci::Build do
it 'has expiring artifacts' do it 'has expiring artifacts' do
expect(build).to have_expiring_archive_artifacts expect(build).to have_expiring_archive_artifacts
end end
context 'and job artifacts are locked' do
before do
archive.update(locked: true)
end
it 'does not have expiring artifacts' do
expect(build).not_to have_expiring_archive_artifacts
end
end
end end
context 'and job artifacts archive record does not exist' do context 'and job artifacts archive record does not exist' do
......
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