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
iv
gitlab-ce
Commits
8eeed761
Commit
8eeed761
authored
Dec 28, 2015
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update specs for CI Build, add `artifacts?` method
`artifacts?` method checks if artifacts archive is available.
parent
9e0e9342
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
41 deletions
+53
-41
app/controllers/projects/artifacts_controller.rb
app/controllers/projects/artifacts_controller.rb
+2
-0
app/models/ci/build.rb
app/models/ci/build.rb
+14
-12
app/views/admin/builds/_build.html.haml
app/views/admin/builds/_build.html.haml
+1
-1
app/views/projects/builds/show.html.haml
app/views/projects/builds/show.html.haml
+1
-1
app/views/projects/commit_statuses/_commit_status.html.haml
app/views/projects/commit_statuses/_commit_status.html.haml
+1
-1
spec/models/build_spec.rb
spec/models/build_spec.rb
+34
-26
No files found.
app/controllers/projects/artifacts_controller.rb
View file @
8eeed761
...
@@ -15,6 +15,8 @@ class Projects::ArtifactsController < Projects::ApplicationController
...
@@ -15,6 +15,8 @@ class Projects::ArtifactsController < Projects::ApplicationController
end
end
def
browse
def
browse
return
render_404
unless
build
.
artifacts?
current_path
=
params
[
:path
]
?
"./
#{
params
[
:path
]
}
/"
:
'./'
current_path
=
params
[
:path
]
?
"./
#{
params
[
:path
]
}
/"
:
'./'
artifacts_metadata
=
build
.
artifacts_metadata
(
current_path
)
artifacts_metadata
=
build
.
artifacts_metadata
(
current_path
)
@path
=
Gitlab
::
StringPath
.
new
(
current_path
,
artifacts_metadata
)
@path
=
Gitlab
::
StringPath
.
new
(
current_path
,
artifacts_metadata
)
...
...
app/models/ci/build.rb
View file @
8eeed761
...
@@ -319,22 +319,24 @@ module Ci
...
@@ -319,22 +319,24 @@ module Ci
pending?
&&
!
any_runners_online?
pending?
&&
!
any_runners_online?
end
end
def
artifacts_download_url
def
execute_hooks
if
artifacts_file
.
exists?
build_data
=
Gitlab
::
BuildDataBuilder
.
build
(
self
)
download_namespace_project_build_artifacts_path
(
project
.
namespace
,
project
,
self
)
project
.
execute_hooks
(
build_data
.
dup
,
:build_hooks
)
end
project
.
execute_services
(
build_data
.
dup
,
:build_hooks
)
end
end
def
artifacts_browse_url
def
artifacts?
if
artifacts_file
.
exists?
artifacts_file
.
exists?
browse_namespace_project_build_artifacts_path
(
project
.
namespace
,
project
,
self
)
end
end
def
artifacts_download_url
download_namespace_project_build_artifacts_path
(
project
.
namespace
,
project
,
self
)
if
artifacts?
end
end
def
execute_hooks
def
artifacts_browse_url
build_data
=
Gitlab
::
BuildDataBuilder
.
build
(
self
)
browse_namespace_project_build_artifacts_path
(
project
.
namespace
,
project
,
self
)
if
project
.
execute_hooks
(
build_data
.
dup
,
:build_hooks
)
artifacts?
project
.
execute_services
(
build_data
.
dup
,
:build_hooks
)
end
end
def
artifacts_metadata
(
path
)
def
artifacts_metadata
(
path
)
...
...
app/views/admin/builds/_build.html.haml
View file @
8eeed761
...
@@ -60,7 +60,7 @@
...
@@ -60,7 +60,7 @@
%td
%td
.pull-right
.pull-right
-
if
current_user
&&
can?
(
current_user
,
:download_build_artifacts
,
project
)
&&
build
.
artifacts
_file
.
exist
?
-
if
current_user
&&
can?
(
current_user
,
:download_build_artifacts
,
project
)
&&
build
.
artifacts?
=
link_to
build
.
artifacts_download_url
,
title:
'Download artifacts'
do
=
link_to
build
.
artifacts_download_url
,
title:
'Download artifacts'
do
%i
.fa.fa-download
%i
.fa.fa-download
-
if
current_user
&&
can?
(
current_user
,
:manage_builds
,
build
.
project
)
-
if
current_user
&&
can?
(
current_user
,
:manage_builds
,
build
.
project
)
...
...
app/views/projects/builds/show.html.haml
View file @
8eeed761
...
@@ -89,7 +89,7 @@
...
@@ -89,7 +89,7 @@
Test coverage
Test coverage
%h1
#{
@build
.
coverage
}
%
%h1
#{
@build
.
coverage
}
%
-
if
current_user
&&
can?
(
current_user
,
:download_build_artifacts
,
@project
)
&&
@build
.
artifacts
_file
.
exist
?
-
if
current_user
&&
can?
(
current_user
,
:download_build_artifacts
,
@project
)
&&
@build
.
artifacts?
.build-widget.center
.build-widget.center
.panel.panel-default
.panel.panel-default
.panel-heading
Build artifacts
.panel-heading
Build artifacts
...
...
app/views/projects/commit_statuses/_commit_status.html.haml
View file @
8eeed761
...
@@ -66,7 +66,7 @@
...
@@ -66,7 +66,7 @@
%td
%td
.pull-right
.pull-right
-
if
current_user
&&
can?
(
current_user
,
:download_build_artifacts
,
commit_status
.
project
)
&&
commit_status
.
artifacts
_file
.
exist
?
-
if
current_user
&&
can?
(
current_user
,
:download_build_artifacts
,
commit_status
.
project
)
&&
commit_status
.
artifacts?
=
link_to
commit_status
.
artifacts_download_url
,
title:
'Download artifacts'
do
=
link_to
commit_status
.
artifacts_download_url
,
title:
'Download artifacts'
do
%i
.fa.fa-download
%i
.fa.fa-download
-
if
current_user
&&
can?
(
current_user
,
:manage_builds
,
commit_status
.
project
)
-
if
current_user
&&
can?
(
current_user
,
:manage_builds
,
commit_status
.
project
)
...
...
spec/models/build_spec.rb
View file @
8eeed761
# == Schema Information
#
# Table name: builds
#
# id :integer not null, primary key
# project_id :integer
# status :string(255)
# finished_at :datetime
# trace :text
# created_at :datetime
# updated_at :datetime
# started_at :datetime
# runner_id :integer
# commit_id :integer
# coverage :float
# commands :text
# job_id :integer
# name :string(255)
# deploy :boolean default(FALSE)
# options :text
# allow_failure :boolean default(FALSE), not null
# stage :string(255)
# trigger_request_id :integer
#
require
'spec_helper'
require
'spec_helper'
describe
Ci
::
Build
,
models:
true
do
describe
Ci
::
Build
,
models:
true
do
...
@@ -376,13 +351,46 @@ describe Ci::Build, models: true do
...
@@ -376,13 +351,46 @@ describe Ci::Build, models: true do
is_expected
.
to
be_nil
is_expected
.
to
be_nil
end
end
it
'should be nil if artifact exist'
do
it
'should not be nil if artifact exist'
do
gif
=
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/banana_sample.gif'
,
'image/gif'
)
build
.
update_attributes
(
artifacts_file:
gif
)
is_expected
.
to_not
be_nil
end
end
describe
:artifacts_browse_url
do
subject
{
build
.
artifacts_browse_url
}
it
"should be nil if artifact doesn't exist"
do
build
.
update_attributes
(
artifacts_file:
nil
)
is_expected
.
to
be_nil
end
it
'should not be nil if artifact exist'
do
gif
=
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/banana_sample.gif'
,
'image/gif'
)
gif
=
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/banana_sample.gif'
,
'image/gif'
)
build
.
update_attributes
(
artifacts_file:
gif
)
build
.
update_attributes
(
artifacts_file:
gif
)
is_expected
.
to_not
be_nil
is_expected
.
to_not
be_nil
end
end
end
end
describe
:artifacts?
do
subject
{
build
.
artifacts?
}
context
'artifacts archive does not exist'
do
before
{
build
.
update_attributes
(
artifacts_file:
nil
)
}
it
{
is_expected
.
to
be_falsy
}
end
context
'artifacts archive exists'
do
before
do
gif
=
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/banana_sample.gif'
,
'image/gif'
)
build
.
update_attributes
(
artifacts_file:
gif
)
end
it
{
is_expected
.
to
be_truthy
}
end
end
describe
:repo_url
do
describe
:repo_url
do
let
(
:build
)
{
FactoryGirl
.
create
:ci_build
}
let
(
:build
)
{
FactoryGirl
.
create
:ci_build
}
let
(
:project
)
{
build
.
project
}
let
(
:project
)
{
build
.
project
}
...
...
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