Commit 2ee86441 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Fixed tests, changed dispatcher routing to the 'repository:show'

Also modified the render calls to the deploy_keys and protected_branches
partials
parent 0b74ae84
...@@ -280,7 +280,7 @@ const UserCallout = require('./user_callout'); ...@@ -280,7 +280,7 @@ const UserCallout = require('./user_callout');
case 'search:show': case 'search:show':
new Search(); new Search();
break; break;
case 'projects:protected_branches:index': case 'projects:repository:show':
new gl.ProtectedBranchCreate(); new gl.ProtectedBranchCreate();
new gl.ProtectedBranchEditList(); new gl.ProtectedBranchEditList();
break; break;
......
...@@ -16,13 +16,11 @@ class Projects::DeployKeysController < Projects::ApplicationController ...@@ -16,13 +16,11 @@ class Projects::DeployKeysController < Projects::ApplicationController
def create def create
@key = DeployKey.new(deploy_key_params.merge(user: current_user)) @key = DeployKey.new(deploy_key_params.merge(user: current_user))
set_index_vars
if @key.valid? && @project.deploy_keys << @key unless @key.valid? && @project.deploy_keys << @key
redirect_to namespace_project_settings_repository_path(@project.namespace, @project) flash[:alert] = @key.errors.full_messages.join(',').html_safe
else
render "index"
end end
redirect_to namespace_project_settings_repository_path(@project.namespace, @project)
end end
def enable def enable
...@@ -34,23 +32,11 @@ class Projects::DeployKeysController < Projects::ApplicationController ...@@ -34,23 +32,11 @@ class Projects::DeployKeysController < Projects::ApplicationController
def disable def disable
@project.deploy_keys_projects.find_by(deploy_key_id: params[:id]).destroy @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 end
protected 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 def deploy_key_params
params.require(:deploy_key).permit(:key, :title, :can_push) params.require(:deploy_key).permit(:key, :title, :can_push)
end end
......
class Projects::ProtectedBranchesController < Projects::ApplicationController class Projects::ProtectedBranchesController < Projects::ApplicationController
include RepositoryHelper
# Authorize # Authorize
before_action :require_non_empty_project before_action :require_non_empty_project
before_action :authorize_admin_project! before_action :authorize_admin_project!
before_action :load_protected_branch, only: [:show, :update, :destroy] before_action :load_protected_branch, only: [:show, :update, :destroy]
before_action :load_protected_branches, only: [:index]
layout "project_settings" layout "project_settings"
...@@ -13,13 +13,10 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController ...@@ -13,13 +13,10 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController
def create def create
@protected_branch = ::ProtectedBranches::CreateService.new(@project, current_user, protected_branch_params).execute @protected_branch = ::ProtectedBranches::CreateService.new(@project, current_user, protected_branch_params).execute
if @protected_branch.persisted? unless @protected_branch.persisted?
redirect_to namespace_project_settings_repository_path(@project.namespace, @project) flash[:alert] = @protected_branches.errors.full_messages.join(',').html_safe
else
load_protected_branches
load_gon_index
render :index
end end
redirect_to namespace_project_settings_repository_path(@project.namespace, @project)
end end
def show def show
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
Enabled deploy keys for this project (#{@enabled_keys.size}) Enabled deploy keys for this project (#{@enabled_keys.size})
- if @enabled_keys.any? - if @enabled_keys.any?
%ul.well-list %ul.well-list
= render @enabled_keys - @enabled_keys.each do |enabled_key|
= render partial: 'projects/deploy_keys/deploy_key', locals: {deploy_key: enabled_key}
- else - else
.settings-message.text-center .settings-message.text-center
No deploy keys found. Create one with the form above or add existing one below. No deploy keys found. Create one with the form above or add existing one below.
...@@ -23,7 +24,8 @@ ...@@ -23,7 +24,8 @@
Deploy keys from projects you have access to (#{@available_project_keys.size}) Deploy keys from projects you have access to (#{@available_project_keys.size})
- if @available_project_keys.any? - if @available_project_keys.any?
%ul.well-list %ul.well-list
= render @available_project_keys - @available_project_keys.each do |available_key|
= render partial: 'projects/deploy_keys/deploy_key', locals: {deploy_key: available_key}
- else - else
.settings-message.text-center .settings-message.text-center
No deploy keys from your projects could be found. Create one with the form above or add existing one below. No deploy keys from your projects could be found. Create one with the form above or add existing one below.
...@@ -31,4 +33,5 @@ ...@@ -31,4 +33,5 @@
%h5.prepend-top-default %h5.prepend-top-default
Public deploy keys available to any project (#{@available_public_keys.size}) Public deploy keys available to any project (#{@available_public_keys.size})
%ul.well-list %ul.well-list
= render @available_public_keys - @available_public_keys.each do |available_key|
= render partial: 'projects/deploy_keys/deploy_key', locals: {deploy_key: available_key}
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
- else - else
(branch was removed from repository) (branch was removed from repository)
= render partial: 'update_protected_branch', locals: { protected_branch: protected_branch } = render partial: 'projects/protected_branches/update_protected_branch', locals: { protected_branch: protected_branch }
- if can_admin_project - if can_admin_project
%td %td
......
...@@ -46,10 +46,10 @@ Feature: Project Active Tab ...@@ -46,10 +46,10 @@ Feature: Project Active Tab
And no other sub navs should be active And no other sub navs should be active
And the active main tab should be Settings And the active main tab should be Settings
Scenario: On Project Settings/Deploy Keys Scenario: On Project Settings/Repository
Given I visit my project's settings page Given I visit my project's settings page
And I click the "Deploy Keys" tab And I click the "Repository" tab
Then the active sub nav should be Deploy Keys Then the active sub nav should be Repository
And no other sub navs should be active And no other sub navs should be active
And the active main tab should be Settings And the active main tab should be Settings
......
...@@ -31,8 +31,10 @@ class Spinach::Features::ProjectActiveTab < Spinach::FeatureSteps ...@@ -31,8 +31,10 @@ class Spinach::Features::ProjectActiveTab < Spinach::FeatureSteps
click_link('Integrations') click_link('Integrations')
end end
step 'I click the "Deploy Keys" tab' do step 'I click the "Repository" tab' do
click_link('Deploy Keys') page.within '.layout-nav .controls' do
click_link('Repository')
end
end end
step 'I click the "Pages" tab' do step 'I click the "Pages" tab' do
...@@ -47,8 +49,8 @@ class Spinach::Features::ProjectActiveTab < Spinach::FeatureSteps ...@@ -47,8 +49,8 @@ class Spinach::Features::ProjectActiveTab < Spinach::FeatureSteps
ensure_active_sub_nav('Integrations') ensure_active_sub_nav('Integrations')
end end
step 'the active sub nav should be Deploy Keys' do step 'the active sub nav should be Repository' do
ensure_active_sub_nav('Deploy Keys') ensure_active_sub_nav('Repository')
end end
step 'the active sub nav should be Pages' do step 'the active sub nav should be Pages' do
......
...@@ -36,7 +36,7 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps ...@@ -36,7 +36,7 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps
end end
step 'I should be on deploy keys page' do step 'I should be on deploy keys page' do
expect(current_path).to eq namespace_project_deploy_keys_path(@project.namespace, @project) expect(current_path).to eq namespace_project_settings_repository_path(@project.namespace, @project)
end end
step 'I should see newly created deploy key' do step 'I should see newly created deploy key' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment