summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2015-10-23 14:06:34 +0000
committerRobert Speicher <robert@gitlab.com>2015-10-23 14:06:34 +0000
commit17c60173f6e2a543c7a92cd2a992ef8bc1ea2ee6 (patch)
treef44dffdd8defe2f2756a50f436ad1d4f2cb0e84e /app/controllers
parent2b51823017faec1d75852bcd318bd502099d692d (diff)
parent5921a1edf3eacc23ed25f39d052ad4db4aac91e2 (diff)
downloadgitlab-ce-17c60173f6e2a543c7a92cd2a992ef8bc1ea2ee6.tar.gz
Merge branch 'fix-ci-regressions' into 'master'
Fix CI regressions This MR fixes a couple of small CI regressions - Allow developer to manage builds - On CI Admin page show only projects that are present in GitLab - On Runner CI Admin page show only projects that are present in GitLab - Refresh build log only when status changes - Show the oldest builds on top when viewing Builds - it most cases it shows running builds on top - Fix Lint rendering - Fix number of other builds in build widget Fixes #3164 Fixes #3161 Fixes gitlab-org/gitlab-ci#343 See merge request !1679
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/ci/admin/runners_controller.rb1
-rw-r--r--app/controllers/ci/application_controller.rb8
-rw-r--r--app/controllers/projects/builds_controller.rb17
-rw-r--r--app/controllers/projects/commit_controller.rb11
4 files changed, 23 insertions, 14 deletions
diff --git a/app/controllers/ci/admin/runners_controller.rb b/app/controllers/ci/admin/runners_controller.rb
index 110954a612d..0cafad27418 100644
--- a/app/controllers/ci/admin/runners_controller.rb
+++ b/app/controllers/ci/admin/runners_controller.rb
@@ -17,6 +17,7 @@ module Ci
@projects = @projects.where(gitlab_id: @gl_projects.select(:id))
end
@projects = @projects.where("ci_projects.id NOT IN (?)", @runner.projects.pluck(:id)) if @runner.projects.any?
+ @projects = @projects.joins(:gl_project)
@projects = @projects.page(params[:page]).per(30)
end
diff --git a/app/controllers/ci/application_controller.rb b/app/controllers/ci/application_controller.rb
index 9be470660e6..848f2b4e314 100644
--- a/app/controllers/ci/application_controller.rb
+++ b/app/controllers/ci/application_controller.rb
@@ -8,14 +8,6 @@ module Ci
private
- def authenticate_public_page!
- unless project.public
- authenticate_user!
-
- return access_denied! unless can?(current_user, :read_project, gl_project)
- end
- end
-
def authenticate_token!
unless project.valid_token?(params[:token])
return head(403)
diff --git a/app/controllers/projects/builds_controller.rb b/app/controllers/projects/builds_controller.rb
index 816012762ce..7d72e0b951b 100644
--- a/app/controllers/projects/builds_controller.rb
+++ b/app/controllers/projects/builds_controller.rb
@@ -2,23 +2,24 @@ class Projects::BuildsController < Projects::ApplicationController
before_action :ci_project
before_action :build, except: [:index, :cancel_all]
- before_action :authorize_admin_project!, except: [:index, :show, :status]
+ before_action :authorize_manage_builds!, except: [:index, :show, :status]
layout "project"
def index
@scope = params[:scope]
@all_builds = project.ci_builds
+ @builds = @all_builds.order('created_at DESC')
@builds =
case @scope
when 'all'
- @all_builds
+ @builds
when 'finished'
- @all_builds.finished
+ @builds.finished
else
- @all_builds.running_or_pending
+ @builds.running_or_pending.reverse_order
end
- @builds = @builds.order('created_at DESC').page(params[:page]).per(30)
+ @builds = @builds.page(params[:page]).per(30)
end
def cancel_all
@@ -73,4 +74,10 @@ class Projects::BuildsController < Projects::ApplicationController
def build_path(build)
namespace_project_build_path(build.gl_project.namespace, build.gl_project, build)
end
+
+ def authorize_manage_builds!
+ unless can?(current_user, :manage_builds, project)
+ return page_404
+ end
+ end
end
diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb
index 7886f3c6deb..878c3a66e7d 100644
--- a/app/controllers/projects/commit_controller.rb
+++ b/app/controllers/projects/commit_controller.rb
@@ -4,7 +4,8 @@
class Projects::CommitController < Projects::ApplicationController
# Authorize
before_action :require_non_empty_project
- before_action :authorize_download_code!
+ before_action :authorize_download_code!, except: [:cancel_builds]
+ before_action :authorize_manage_builds!, only: [:cancel_builds]
before_action :commit
def show
@@ -55,4 +56,12 @@ class Projects::CommitController < Projects::ApplicationController
def commit
@commit ||= @project.commit(params[:id])
end
+
+ private
+
+ def authorize_manage_builds!
+ unless can?(current_user, :manage_builds, project)
+ return page_404
+ end
+ end
end