Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
5d0537bb
Commit
5d0537bb
authored
May 25, 2020
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for artifact locking in artifact_*? methods
parent
8a13ab76
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
11 deletions
+43
-11
app/models/ci/build.rb
app/models/ci/build.rb
+8
-0
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+35
-11
No files found.
app/models/ci/build.rb
View file @
5d0537bb
...
@@ -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
...
...
spec/models/ci/build_spec.rb
View file @
5d0537bb
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment