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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
5456859b
Commit
5456859b
authored
Jan 09, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add method that checks for expiring build artifacts
parent
4a7e1423
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
17 deletions
+40
-17
app/models/ci/build.rb
app/models/ci/build.rb
+4
-0
app/views/projects/builds/_sidebar.html.haml
app/views/projects/builds/_sidebar.html.haml
+2
-2
spec/features/projects/builds_spec.rb
spec/features/projects/builds_spec.rb
+2
-2
spec/models/build_spec.rb
spec/models/build_spec.rb
+32
-13
No files found.
app/models/ci/build.rb
View file @
5456859b
...
@@ -507,6 +507,10 @@ module Ci
...
@@ -507,6 +507,10 @@ module Ci
end
end
end
end
def
has_expiring_artifacts?
artifacts_expire_at
.
present?
end
def
keep_artifacts!
def
keep_artifacts!
self
.
update
(
artifacts_expire_at:
nil
)
self
.
update
(
artifacts_expire_at:
nil
)
end
end
...
...
app/views/projects/builds/_sidebar.html.haml
View file @
5456859b
...
@@ -22,14 +22,14 @@
...
@@ -22,14 +22,14 @@
%p
.build-detail-row
%p
.build-detail-row
The artifacts were removed
The artifacts were removed
#{
time_ago_with_tooltip
(
@build
.
artifacts_expire_at
)
}
#{
time_ago_with_tooltip
(
@build
.
artifacts_expire_at
)
}
-
elsif
@build
.
artifacts_expire_at
-
elsif
@build
.
has_expiring_artifacts?
%p
.build-detail-row
%p
.build-detail-row
The artifacts will be removed in
The artifacts will be removed in
%span
.js-artifacts-remove
=
@build
.
artifacts_expire_at
%span
.js-artifacts-remove
=
@build
.
artifacts_expire_at
-
if
@build
.
artifacts?
-
if
@build
.
artifacts?
.btn-group.btn-group-justified
{
role: :group
}
.btn-group.btn-group-justified
{
role: :group
}
-
if
@build
.
artifacts_expire_at
&&
can?
(
current_user
,
:update_build
,
@build
)
-
if
@build
.
has_expiring_artifacts?
&&
can?
(
current_user
,
:update_build
,
@build
)
=
link_to
keep_namespace_project_build_artifacts_path
(
@project
.
namespace
,
@project
,
@build
),
class:
'btn btn-sm btn-default'
,
method: :post
do
=
link_to
keep_namespace_project_build_artifacts_path
(
@project
.
namespace
,
@project
,
@build
),
class:
'btn btn-sm btn-default'
,
method: :post
do
Keep
Keep
...
...
spec/features/projects/builds_spec.rb
View file @
5456859b
...
@@ -155,8 +155,8 @@ feature 'Builds', :feature do
...
@@ -155,8 +155,8 @@ feature 'Builds', :feature do
click_link
'Keep'
click_link
'Keep'
expect
(
page
).
not_to
have
_link
'Keep'
expect
(
page
).
to
have_no
_link
'Keep'
expect
(
page
).
not_to
have
_content
'The artifacts will be removed'
expect
(
page
).
to
have_no
_content
'The artifacts will be removed'
end
end
end
end
...
...
spec/models/build_spec.rb
View file @
5456859b
...
@@ -652,6 +652,24 @@ describe Ci::Build, models: true do
...
@@ -652,6 +652,24 @@ describe Ci::Build, models: true do
end
end
end
end
describe
'#has_expiring_artifacts?'
do
context
'when artifacts have expiration date set'
do
before
{
build
.
update
(
artifacts_expire_at:
1
.
day
.
from_now
)
}
it
'has expiring artifacts'
do
expect
(
build
).
to
have_expiring_artifacts
end
end
context
'when artifacts do not have expiration date set'
do
before
{
build
.
update
(
artifacts_expire_at:
nil
)
}
it
'does not have expiring artifacts'
do
expect
(
build
).
not_to
have_expiring_artifacts
end
end
end
describe
'#artifacts_metadata?'
do
describe
'#artifacts_metadata?'
do
subject
{
build
.
artifacts_metadata?
}
subject
{
build
.
artifacts_metadata?
}
context
'artifacts metadata does not exist'
do
context
'artifacts metadata does not exist'
do
...
@@ -663,19 +681,6 @@ describe Ci::Build, models: true do
...
@@ -663,19 +681,6 @@ describe Ci::Build, models: true do
it
{
is_expected
.
to
be_truthy
}
it
{
is_expected
.
to
be_truthy
}
end
end
end
end
describe
'#repo_url'
do
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:project
)
{
build
.
project
}
subject
{
build
.
repo_url
}
it
{
is_expected
.
to
be_a
(
String
)
}
it
{
is_expected
.
to
end_with
(
".git"
)
}
it
{
is_expected
.
to
start_with
(
project
.
web_url
[
0
..
6
])
}
it
{
is_expected
.
to
include
(
build
.
token
)
}
it
{
is_expected
.
to
include
(
'gitlab-ci-token'
)
}
it
{
is_expected
.
to
include
(
project
.
web_url
[
7
..-
1
])
}
end
describe
'#artifacts_expire_in'
do
describe
'#artifacts_expire_in'
do
subject
{
build
.
artifacts_expire_in
}
subject
{
build
.
artifacts_expire_in
}
...
@@ -721,6 +726,20 @@ describe Ci::Build, models: true do
...
@@ -721,6 +726,20 @@ describe Ci::Build, models: true do
end
end
end
end
describe
'#repo_url'
do
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:project
)
{
build
.
project
}
subject
{
build
.
repo_url
}
it
{
is_expected
.
to
be_a
(
String
)
}
it
{
is_expected
.
to
end_with
(
".git"
)
}
it
{
is_expected
.
to
start_with
(
project
.
web_url
[
0
..
6
])
}
it
{
is_expected
.
to
include
(
build
.
token
)
}
it
{
is_expected
.
to
include
(
'gitlab-ci-token'
)
}
it
{
is_expected
.
to
include
(
project
.
web_url
[
7
..-
1
])
}
end
describe
'#depends_on_builds'
do
describe
'#depends_on_builds'
do
let!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'build'
,
stage_idx:
0
,
stage:
'build'
)
}
let!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'build'
,
stage_idx:
0
,
stage:
'build'
)
}
let!
(
:rspec_test
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'rspec'
,
stage_idx:
1
,
stage:
'test'
)
}
let!
(
:rspec_test
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'rspec'
,
stage_idx:
1
,
stage:
'test'
)
}
...
...
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