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
Jérome Perrin
gitlab-ce
Commits
7e9273dd
Commit
7e9273dd
authored
Jun 10, 2016
by
Kamil Trzcinski
Committed by
Phil Hughes
Jun 13, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test controllers if they allow to keep artifacts
parent
304979f8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
1 deletion
+109
-1
app/controllers/projects/artifacts_controller.rb
app/controllers/projects/artifacts_controller.rb
+1
-0
spec/features/builds_spec.rb
spec/features/builds_spec.rb
+44
-0
spec/models/build_spec.rb
spec/models/build_spec.rb
+64
-1
No files found.
app/controllers/projects/artifacts_controller.rb
View file @
7e9273dd
class
Projects::ArtifactsController
<
Projects
::
ApplicationController
class
Projects::ArtifactsController
<
Projects
::
ApplicationController
layout
'project'
layout
'project'
before_action
:authorize_read_build!
before_action
:authorize_read_build!
before_action
:authorize_update_build!
,
only:
[
:keep
]
before_action
:validate_artifacts!
before_action
:validate_artifacts!
def
download
def
download
...
...
spec/features/builds_spec.rb
View file @
7e9273dd
...
@@ -97,6 +97,48 @@ describe "Builds" do
...
@@ -97,6 +97,48 @@ describe "Builds" do
end
end
end
end
context
'Artifacts expire date'
do
before
do
@build
.
update_attributes
(
artifacts_file:
artifacts_file
,
artifacts_expire_at:
expire_at
)
visit
namespace_project_build_path
(
@project
.
namespace
,
@project
,
@build
)
end
context
'no expire date defined'
do
let
(
:expire_at
)
{
nil
}
it
'should not have the Keep button'
do
page
.
within
(
'.artifacts'
)
do
expect
(
page
).
not_to
have_content
'Keep'
end
end
end
context
'when expire date is defined'
do
let
(
:expire_at
)
{
Time
.
now
+
7
.
days
}
it
'should keep artifacts when Keep button is clicked'
do
page
.
within
(
'.artifacts'
)
do
expect
(
page
).
to
have_content
'The artifacts will be removed'
click_link
'Keep'
end
expect
(
page
).
not_to
have_link
'Keep'
expect
(
page
).
not_to
have_content
'The artifacts will be removed'
end
end
context
'when artifacts expired'
do
let
(
:expire_at
)
{
Time
.
now
-
7
.
days
}
it
'should not have the Keep button'
do
page
.
within
(
'.artifacts'
)
do
expect
(
page
).
to
have_content
'The artifacts were removed'
expect
(
page
).
not_to
have_link
'Keep'
end
end
end
end
context
'Build raw trace'
do
context
'Build raw trace'
do
before
do
before
do
@build
.
run!
@build
.
run!
...
@@ -108,6 +150,8 @@ describe "Builds" do
...
@@ -108,6 +150,8 @@ describe "Builds" do
expect
(
page
).
to
have_link
'Raw'
expect
(
page
).
to
have_link
'Raw'
end
end
end
end
context
''
end
end
describe
"POST /:project/builds/:id/cancel"
do
describe
"POST /:project/builds/:id/cancel"
do
...
...
spec/models/build_spec.rb
View file @
7e9273dd
...
@@ -397,9 +397,32 @@ describe Ci::Build, models: true do
...
@@ -397,9 +397,32 @@ describe Ci::Build, models: true do
context
'artifacts archive exists'
do
context
'artifacts archive exists'
do
let
(
:build
)
{
create
(
:ci_build
,
:artifacts
)
}
let
(
:build
)
{
create
(
:ci_build
,
:artifacts
)
}
it
{
is_expected
.
to
be_truthy
}
it
{
is_expected
.
to
be_truthy
}
context
'is expired'
do
before
{
build
.
update
(
artifacts_expire_at:
Time
.
now
-
7
.
days
)
}
it
{
is_expected
.
to
be_falsy
}
end
context
'is not expired'
do
before
{
build
.
update
(
artifacts_expire_at:
Time
.
now
+
7
.
days
)
}
it
{
is_expected
.
to
be_truthy
}
end
end
end
end
end
describe
'#artifacts_expired?'
do
subject
{
build
.
artifacts_expired?
}
context
'is expired'
do
before
{
build
.
update
(
artifacts_expire_at:
Time
.
now
-
7
.
days
)
}
it
{
is_expected
.
to
be_falsy
}
end
context
'is not expired'
do
before
{
build
.
update
(
artifacts_expire_at:
Time
.
now
+
7
.
days
)
}
it
{
is_expected
.
to
be_truthy
}
end
end
describe
'#artifacts_metadata?'
do
describe
'#artifacts_metadata?'
do
subject
{
build
.
artifacts_metadata?
}
subject
{
build
.
artifacts_metadata?
}
...
@@ -412,7 +435,6 @@ describe Ci::Build, models: true do
...
@@ -412,7 +435,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
describe
'#repo_url'
do
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:project
)
{
build
.
project
}
let
(
:project
)
{
build
.
project
}
...
@@ -427,6 +449,47 @@ describe Ci::Build, models: true do
...
@@ -427,6 +449,47 @@ describe Ci::Build, models: true do
it
{
is_expected
.
to
include
(
project
.
web_url
[
7
..-
1
])
}
it
{
is_expected
.
to
include
(
project
.
web_url
[
7
..-
1
])
}
end
end
describe
'#artifacts_expire_in'
do
subject
{
build
.
artifacts_expire_in
}
it
{
is_expected
.
to
be_nil
}
context
'when artifacts_expire_at is specified'
do
let
(
:expire_at
)
{
Time
.
now
+
7
.
days
}
before
{
build
.
artifacts_expire_at
=
expire_at
}
it
{
is_expected
.
to
be_within
(
5
).
of
(
expire_at
-
Time
.
now
)
}
end
end
describe
'#artifacts_expire_in='
do
subject
{
build
.
artifacts_expire_in
}
it
'when assigning valid duration'
do
build
.
artifacts_expire_in
=
'7 days'
is_expected
.
to
be_within
(
10
).
of
(
7
.
days
.
to_i
)
end
it
'when assigning invalid duration'
do
expect
{
build
.
artifacts_expire_in
=
'7 elephants'
}.
not_to
raise_error
is_expected
.
to
be_nil
end
it
'when resseting value'
do
build
.
artifacts_expire_in
=
nil
is_expected
.
to
be_nil
end
end
describe
'#keep_artifacts!'
do
let
(
:build
)
{
create
(
:ci_build
,
artifacts_expire_at:
Time
.
now
+
7
.
days
)
}
it
'to reset expire_at'
do
build
.
keep_artifacts!
expect
(
build
.
artifacts_expire_at
).
to
be_nil
end
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