diff options
author | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-01-30 13:21:02 -0600 |
---|---|---|
committer | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-03-06 09:47:44 -0600 |
commit | 2ee86441158076344a07f2715a148a5bdbe161b0 (patch) | |
tree | 2bf1f0dc0c49b3e888e7cd8ad6875e14899f0fef /app/controllers | |
parent | 0b74ae849d3f87564e789673ecf67aa54ec7cd8a (diff) | |
download | gitlab-ce-2ee86441158076344a07f2715a148a5bdbe161b0.tar.gz |
Fixed tests, changed dispatcher routing to the 'repository:show'
Also modified the render calls to the deploy_keys and protected_branches
partials
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/projects/deploy_keys_controller.rb | 22 | ||||
-rw-r--r-- | app/controllers/projects/protected_branches_controller.rb | 11 |
2 files changed, 8 insertions, 25 deletions
diff --git a/app/controllers/projects/deploy_keys_controller.rb b/app/controllers/projects/deploy_keys_controller.rb index 07410afd99a..0d60e782dfb 100644 --- a/app/controllers/projects/deploy_keys_controller.rb +++ b/app/controllers/projects/deploy_keys_controller.rb @@ -16,13 +16,11 @@ class Projects::DeployKeysController < Projects::ApplicationController def create @key = DeployKey.new(deploy_key_params.merge(user: current_user)) - set_index_vars - if @key.valid? && @project.deploy_keys << @key - redirect_to namespace_project_settings_repository_path(@project.namespace, @project) - else - render "index" + unless @key.valid? && @project.deploy_keys << @key + flash[:alert] = @key.errors.full_messages.join(',').html_safe end + redirect_to namespace_project_settings_repository_path(@project.namespace, @project) end def enable @@ -34,23 +32,11 @@ class Projects::DeployKeysController < Projects::ApplicationController def disable @project.deploy_keys_projects.find_by(deploy_key_id: params[:id]).destroy - redirect_back_or_default(default: { action: 'index' }) + redirect_to namespace_project_settings_repository_path(@project.namespace, @project) end protected - def set_index_vars - @enabled_keys ||= @project.deploy_keys - - @available_keys ||= current_user.accessible_deploy_keys - @enabled_keys - @available_project_keys ||= current_user.project_deploy_keys - @enabled_keys - @available_public_keys ||= DeployKey.are_public - @enabled_keys - - # Public keys that are already used by another accessible project are already - # in @available_project_keys. - @available_public_keys -= @available_project_keys - end - def deploy_key_params params.require(:deploy_key).permit(:key, :title, :can_push) end diff --git a/app/controllers/projects/protected_branches_controller.rb b/app/controllers/projects/protected_branches_controller.rb index 18d25f91c96..ac886f0739a 100644 --- a/app/controllers/projects/protected_branches_controller.rb +++ b/app/controllers/projects/protected_branches_controller.rb @@ -1,9 +1,9 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController + include RepositoryHelper # Authorize before_action :require_non_empty_project before_action :authorize_admin_project! before_action :load_protected_branch, only: [:show, :update, :destroy] - before_action :load_protected_branches, only: [:index] layout "project_settings" @@ -13,13 +13,10 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController def create @protected_branch = ::ProtectedBranches::CreateService.new(@project, current_user, protected_branch_params).execute - if @protected_branch.persisted? - redirect_to namespace_project_settings_repository_path(@project.namespace, @project) - else - load_protected_branches - load_gon_index - render :index + unless @protected_branch.persisted? + flash[:alert] = @protected_branches.errors.full_messages.join(',').html_safe end + redirect_to namespace_project_settings_repository_path(@project.namespace, @project) end def show |