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
d01f2541
Commit
d01f2541
authored
Aug 11, 2020
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract artifact existence check into method
parent
16ce6833
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
3 deletions
+64
-3
app/controllers/projects/artifacts_controller.rb
app/controllers/projects/artifacts_controller.rb
+1
-3
app/models/ci/build.rb
app/models/ci/build.rb
+7
-0
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+56
-0
No files found.
app/controllers/projects/artifacts_controller.rb
View file @
d01f2541
...
...
@@ -108,9 +108,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
end
def
validate_artifacts!
if
build
.
nil?
||
build
.
artifacts_file
.
nil?
||
(
build
.
pipeline
.
unlocked?
&&
build
.
artifacts_expired?
)
render_404
end
render_404
unless
build
&
.
available_artifacts?
end
def
build
...
...
app/models/ci/build.rb
View file @
d01f2541
...
...
@@ -647,6 +647,13 @@ module Ci
!
artifacts_expired?
&&
artifacts_file
&
.
exists?
end
# This method is similar to #artifacts? but it includes the artifacts
# locking mechanics. A new method was created to prevent breaking existing
# behavior and avoid introducing N+1s.
def
available_artifacts?
(
!
artifacts_expired?
||
pipeline
.
artifacts_locked?
)
&&
job_artifacts_archive
&
.
exists?
end
def
artifacts_metadata?
artifacts?
&&
artifacts_metadata
&
.
exists?
end
...
...
spec/models/ci/build_spec.rb
View file @
d01f2541
...
...
@@ -612,6 +612,62 @@ RSpec.describe Ci::Build do
end
end
describe
'#available_artifacts?'
do
let
(
:build
)
{
create
(
:ci_build
)
}
subject
{
build
.
available_artifacts?
}
context
'when artifacts are not expired'
do
before
do
build
.
artifacts_expire_at
=
Date
.
tomorrow
end
context
'when artifacts exist'
do
before
do
create
(
:ci_job_artifact
,
:archive
,
job:
build
)
end
it
{
is_expected
.
to
be_truthy
}
end
context
'when artifacts do not exist'
do
it
{
is_expected
.
to
be_falsey
}
end
end
context
'when artifacts are expired'
do
before
do
build
.
artifacts_expire_at
=
Date
.
yesterday
end
context
'when artifacts are not locked'
do
before
do
build
.
pipeline
.
locked
=
:unlocked
end
it
{
is_expected
.
to
be_falsey
}
end
context
'when artifacts are locked'
do
before
do
build
.
pipeline
.
locked
=
:artifacts_locked
end
context
'when artifacts exist'
do
before
do
create
(
:ci_job_artifact
,
:archive
,
job:
build
)
end
it
{
is_expected
.
to
be_truthy
}
end
context
'when artifacts do not exist'
do
it
{
is_expected
.
to
be_falsey
}
end
end
end
end
describe
'#browsable_artifacts?'
do
subject
{
build
.
browsable_artifacts?
}
...
...
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