Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Ivan Vargas <jvargas@gitlab.com>2017-01-30 22:21:02 +0300
committerJose Ivan Vargas <jvargas@gitlab.com>2017-03-06 18:47:44 +0300
commit2ee86441158076344a07f2715a148a5bdbe161b0 (patch)
tree2bf1f0dc0c49b3e888e7cd8ad6875e14899f0fef
parent0b74ae849d3f87564e789673ecf67aa54ec7cd8a (diff)
Fixed tests, changed dispatcher routing to the 'repository:show'
Also modified the render calls to the deploy_keys and protected_branches partials
-rw-r--r--app/assets/javascripts/dispatcher.js2
-rw-r--r--app/controllers/projects/deploy_keys_controller.rb22
-rw-r--r--app/controllers/projects/protected_branches_controller.rb11
-rw-r--r--app/views/projects/deploy_keys/_index.html.haml9
-rw-r--r--app/views/projects/protected_branches/_protected_branch.html.haml2
-rw-r--r--features/project/active_tab.feature6
-rw-r--r--features/steps/project/active_tab.rb10
-rw-r--r--features/steps/project/deploy_keys.rb2
8 files changed, 26 insertions, 38 deletions
diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js
index ef5785b5532..ac6859b43a0 100644
--- a/app/assets/javascripts/dispatcher.js
+++ b/app/assets/javascripts/dispatcher.js
@@ -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;
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
diff --git a/app/views/projects/deploy_keys/_index.html.haml b/app/views/projects/deploy_keys/_index.html.haml
index 57de5be89cc..c41fb892862 100644
--- a/app/views/projects/deploy_keys/_index.html.haml
+++ b/app/views/projects/deploy_keys/_index.html.haml
@@ -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}
diff --git a/app/views/projects/protected_branches/_protected_branch.html.haml b/app/views/projects/protected_branches/_protected_branch.html.haml
index 0193800dedf..b2a6b8469a3 100644
--- a/app/views/projects/protected_branches/_protected_branch.html.haml
+++ b/app/views/projects/protected_branches/_protected_branch.html.haml
@@ -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
diff --git a/features/project/active_tab.feature b/features/project/active_tab.feature
index 1dd2bdd9b36..4bdaa6266c3 100644
--- a/features/project/active_tab.feature
+++ b/features/project/active_tab.feature
@@ -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
diff --git a/features/steps/project/active_tab.rb b/features/steps/project/active_tab.rb
index e842d7bec2b..218d5c6164b 100644
--- a/features/steps/project/active_tab.rb
+++ b/features/steps/project/active_tab.rb
@@ -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
diff --git a/features/steps/project/deploy_keys.rb b/features/steps/project/deploy_keys.rb
index edf78f62f9a..580a19494c2 100644
--- a/features/steps/project/deploy_keys.rb
+++ b/features/steps/project/deploy_keys.rb
@@ -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