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

Also modified the render calls to the deploy_keys and protected_branches
partials
This commit is contained in:
Jose Ivan Vargas 2017-01-30 13:21:02 -06:00
parent 0b74ae849d
commit 2ee8644115
8 changed files with 26 additions and 38 deletions

View file

@ -280,7 +280,7 @@ const UserCallout = require('./user_callout');
case 'search:show':
new Search();
break;
case 'projects:protected_branches:index':
case 'projects:repository:show':
new gl.ProtectedBranchCreate();
new gl.ProtectedBranchEditList();
break;

View file

@ -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

View file

@ -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

View file

@ -15,7 +15,8 @@
Enabled deploy keys for this project (#{@enabled_keys.size})
- if @enabled_keys.any?
%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
.settings-message.text-center
No deploy keys found. Create one with the form above or add existing one below.
@ -23,7 +24,8 @@
Deploy keys from projects you have access to (#{@available_project_keys.size})
- if @available_project_keys.any?
%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
.settings-message.text-center
No deploy keys from your projects could be found. Create one with the form above or add existing one below.
@ -31,4 +33,5 @@
%h5.prepend-top-default
Public deploy keys available to any project (#{@available_public_keys.size})
%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}

View file

@ -14,7 +14,7 @@
- else
(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
%td

View file

@ -46,10 +46,10 @@ Feature: Project Active Tab
And no other sub navs should be active
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
And I click the "Deploy Keys" tab
Then the active sub nav should be Deploy Keys
And I click the "Repository" tab
Then the active sub nav should be Repository
And no other sub navs should be active
And the active main tab should be Settings

View file

@ -31,8 +31,10 @@ class Spinach::Features::ProjectActiveTab < Spinach::FeatureSteps
click_link('Integrations')
end
step 'I click the "Deploy Keys" tab' do
click_link('Deploy Keys')
step 'I click the "Repository" tab' do
page.within '.layout-nav .controls' do
click_link('Repository')
end
end
step 'I click the "Pages" tab' do
@ -47,8 +49,8 @@ class Spinach::Features::ProjectActiveTab < Spinach::FeatureSteps
ensure_active_sub_nav('Integrations')
end
step 'the active sub nav should be Deploy Keys' do
ensure_active_sub_nav('Deploy Keys')
step 'the active sub nav should be Repository' do
ensure_active_sub_nav('Repository')
end
step 'the active sub nav should be Pages' do

View file

@ -36,7 +36,7 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps
end
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
step 'I should see newly created deploy key' do