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
2c352f9d
Commit
2c352f9d
authored
Oct 05, 2020
by
Matija Čupić
Committed by
Imre Farkas
Oct 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add helper for expired locked artifacts
Add method for checking if build has expired locked artifacts archive.
parent
5497fa47
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
10 deletions
+92
-10
app/models/ci/build.rb
app/models/ci/build.rb
+5
-0
app/serializers/build_details_entity.rb
app/serializers/build_details_entity.rb
+1
-1
changelogs/unreleased/mc-feature-fix-keep-path-artifact-locking.yml
.../unreleased/mc-feature-fix-keep-path-artifact-locking.yml
+5
-0
spec/controllers/projects/jobs_controller_spec.rb
spec/controllers/projects/jobs_controller_spec.rb
+33
-9
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+48
-0
No files found.
app/models/ci/build.rb
View file @
2c352f9d
...
@@ -782,6 +782,11 @@ module Ci
...
@@ -782,6 +782,11 @@ module Ci
end
end
end
end
def
has_expired_locked_archive_artifacts?
locked_artifacts?
&&
artifacts_expire_at
.
present?
&&
artifacts_expire_at
<
Time
.
current
end
def
has_expiring_archive_artifacts?
def
has_expiring_archive_artifacts?
has_expiring_artifacts?
&&
job_artifacts_archive
.
present?
has_expiring_artifacts?
&&
job_artifacts_archive
.
present?
end
end
...
...
app/serializers/build_details_entity.rb
View file @
2c352f9d
...
@@ -35,7 +35,7 @@ class BuildDetailsEntity < JobEntity
...
@@ -35,7 +35,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
.
locked
_artifacts?
||
build
.
has_expiring_archive_artifacts?
)
&&
can?
(
current_user
,
:update_build
,
build
)
}
do
|
build
|
expose
:keep_path
,
if:
->
(
*
)
{
(
build
.
has_expired_locked_archive
_artifacts?
||
build
.
has_expiring_archive_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
...
...
changelogs/unreleased/mc-feature-fix-keep-path-artifact-locking.yml
0 → 100644
View file @
2c352f9d
---
title
:
Show keep path for expired locked artifacts.
merge_request
:
43866
author
:
type
:
changed
spec/controllers/projects/jobs_controller_spec.rb
View file @
2c352f9d
...
@@ -197,16 +197,40 @@ RSpec.describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -197,16 +197,40 @@ RSpec.describe Projects::JobsController, :clean_gitlab_redis_shared_state do
context
'with not expiry date'
do
context
'with not expiry date'
do
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
)
}
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
)
}
it
'exposes needed information'
do
context
'when artifacts are unlocked'
do
get_show_json
before
do
job
.
pipeline
.
unlocked!
end
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
it
'exposes needed information'
do
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
get_show_json
expect
(
json_response
[
'artifact'
][
'download_path'
]).
to
match
(
%r{artifacts/download}
)
expect
(
json_response
[
'artifact'
][
'browse_path'
]).
to
match
(
%r{artifacts/browse}
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'artifact'
]).
not_to
have_key
(
'keep_path'
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'artifact'
]).
not_to
have_key
(
'expired'
)
expect
(
json_response
[
'artifact'
][
'download_path'
]).
to
match
(
%r{artifacts/download}
)
expect
(
json_response
[
'artifact'
]).
not_to
have_key
(
'expired_at'
)
expect
(
json_response
[
'artifact'
][
'browse_path'
]).
to
match
(
%r{artifacts/browse}
)
expect
(
json_response
[
'artifact'
]).
not_to
have_key
(
'keep_path'
)
expect
(
json_response
[
'artifact'
]).
not_to
have_key
(
'expired'
)
expect
(
json_response
[
'artifact'
]).
not_to
have_key
(
'expired_at'
)
end
end
context
'when artifacts are locked'
do
before
do
job
.
pipeline
.
artifacts_locked!
end
it
'exposes needed information'
do
get_show_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'artifact'
][
'download_path'
]).
to
match
(
%r{artifacts/download}
)
expect
(
json_response
[
'artifact'
][
'browse_path'
]).
to
match
(
%r{artifacts/browse}
)
expect
(
json_response
[
'artifact'
]).
not_to
have_key
(
'keep_path'
)
expect
(
json_response
[
'artifact'
]).
not_to
have_key
(
'expired'
)
expect
(
json_response
[
'artifact'
]).
not_to
have_key
(
'expired_at'
)
end
end
end
end
end
...
...
spec/models/ci/build_spec.rb
View file @
2c352f9d
...
@@ -2305,6 +2305,54 @@ RSpec.describe Ci::Build do
...
@@ -2305,6 +2305,54 @@ RSpec.describe Ci::Build do
end
end
end
end
describe
'#has_expired_locked_archive_artifacts?'
do
subject
{
build
.
has_expired_locked_archive_artifacts?
}
context
'when build does not have artifacts'
do
it
{
is_expected
.
to
eq
(
nil
)
}
end
context
'when build has artifacts'
do
before
do
create
(
:ci_job_artifact
,
:archive
,
job:
build
)
end
context
'when artifacts are unlocked'
do
before
do
build
.
pipeline
.
unlocked!
end
it
{
is_expected
.
to
eq
(
false
)
}
end
context
'when artifacts are locked'
do
before
do
build
.
pipeline
.
artifacts_locked!
end
context
'when artifacts do not expire'
do
it
{
is_expected
.
to
eq
(
false
)
}
end
context
'when artifacts expire in the future'
do
before
do
build
.
update!
(
artifacts_expire_at:
1
.
day
.
from_now
)
end
it
{
is_expected
.
to
eq
(
false
)
}
end
context
'when artifacts expired in the past'
do
before
do
build
.
update!
(
artifacts_expire_at:
1
.
day
.
ago
)
end
it
{
is_expected
.
to
eq
(
true
)
}
end
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
...
...
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