summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2015-12-28 11:43:15 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-01-14 12:48:14 +0100
commit8eeed761a9c25ea8ccfc347fbd3f5894b5957d9e (patch)
treeb5a07923abb806e7b24ce5cacba905288023bb1a /app
parent9e0e9342a47022a9caaa4a5596ec3ddb91fddc58 (diff)
downloadgitlab-ce-8eeed761a9c25ea8ccfc347fbd3f5894b5957d9e.tar.gz
Update specs for CI Build, add `artifacts?` method
`artifacts?` method checks if artifacts archive is available.
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects/artifacts_controller.rb2
-rw-r--r--app/models/ci/build.rb26
-rw-r--r--app/views/admin/builds/_build.html.haml2
-rw-r--r--app/views/projects/builds/show.html.haml2
-rw-r--r--app/views/projects/commit_statuses/_commit_status.html.haml2
5 files changed, 19 insertions, 15 deletions
diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb
index 399aa11fcbe..18677fb1e95 100644
--- a/app/controllers/projects/artifacts_controller.rb
+++ b/app/controllers/projects/artifacts_controller.rb
@@ -15,6 +15,8 @@ class Projects::ArtifactsController < Projects::ApplicationController
end
def browse
+ return render_404 unless build.artifacts?
+
current_path = params[:path] ? "./#{params[:path]}/" : './'
artifacts_metadata = build.artifacts_metadata(current_path)
@path = Gitlab::StringPath.new(current_path, artifacts_metadata)
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 9adbfdd2c92..327114e0350 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -319,24 +319,26 @@ module Ci
pending? && !any_runners_online?
end
- def artifacts_download_url
- if artifacts_file.exists?
- download_namespace_project_build_artifacts_path(project.namespace, project, self)
- end
- end
-
- def artifacts_browse_url
- if artifacts_file.exists?
- browse_namespace_project_build_artifacts_path(project.namespace, project, self)
- end
- end
-
def execute_hooks
build_data = Gitlab::BuildDataBuilder.build(self)
project.execute_hooks(build_data.dup, :build_hooks)
project.execute_services(build_data.dup, :build_hooks)
end
+ def artifacts?
+ artifacts_file.exists?
+ end
+
+ def artifacts_download_url
+ download_namespace_project_build_artifacts_path(project.namespace, project, self) if
+ artifacts?
+ end
+
+ def artifacts_browse_url
+ browse_namespace_project_build_artifacts_path(project.namespace, project, self) if
+ artifacts?
+ end
+
def artifacts_metadata(path)
[]
end
diff --git a/app/views/admin/builds/_build.html.haml b/app/views/admin/builds/_build.html.haml
index 7cd98c0f540..26cdb162b76 100644
--- a/app/views/admin/builds/_build.html.haml
+++ b/app/views/admin/builds/_build.html.haml
@@ -60,7 +60,7 @@
%td
.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
%i.fa.fa-download
- if current_user && can?(current_user, :manage_builds, build.project)
diff --git a/app/views/projects/builds/show.html.haml b/app/views/projects/builds/show.html.haml
index 5780d7ad175..c7fd047949e 100644
--- a/app/views/projects/builds/show.html.haml
+++ b/app/views/projects/builds/show.html.haml
@@ -89,7 +89,7 @@
Test 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
.panel.panel-default
.panel-heading Build artifacts
diff --git a/app/views/projects/commit_statuses/_commit_status.html.haml b/app/views/projects/commit_statuses/_commit_status.html.haml
index 5e7f55fdbff..7872eec72b0 100644
--- a/app/views/projects/commit_statuses/_commit_status.html.haml
+++ b/app/views/projects/commit_statuses/_commit_status.html.haml
@@ -66,7 +66,7 @@
%td
.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
%i.fa.fa-download
- if current_user && can?(current_user, :manage_builds, commit_status.project)