summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-07-20 14:33:13 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2016-07-20 14:39:06 +0200
commit52d5d7daf13291416050de23c8635dd59373f3b7 (patch)
tree070364c000eafcd4221dcb789920d89342c98dc4
parent7e8ef1b853b2d95ba99ac597992724b51163fde6 (diff)
downloadgitlab-ce-52d5d7daf13291416050de23c8635dd59373f3b7.tar.gz
Create PipelinesSettingsController for showing settings page
-rw-r--r--app/controllers/projects/pipelines_controller.rb27
-rw-r--r--app/controllers/projects/pipelines_settings_controller.rb33
-rw-r--r--app/controllers/projects/refs_controller.rb2
-rw-r--r--app/views/layouts/nav/_project_settings.html.haml4
-rw-r--r--app/views/projects/pipelines_settings/show.html.haml (renamed from app/views/projects/pipelines/settings.html.haml)2
-rw-r--r--config/routes.rb4
-rw-r--r--spec/features/pipelines_settings_spec.rb35
-rw-r--r--spec/features/pipelines_spec.rb31
-rw-r--r--spec/features/projects/badges/list_spec.rb2
9 files changed, 79 insertions, 61 deletions
diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb
index 55b68b89d0d..487963fdcd7 100644
--- a/app/controllers/projects/pipelines_controller.rb
+++ b/app/controllers/projects/pipelines_controller.rb
@@ -1,10 +1,9 @@
class Projects::PipelinesController < Projects::ApplicationController
- before_action :pipeline, except: [:index, :new, :create, :settings, :update_settings]
+ before_action :pipeline, except: [:index, :new, :create]
before_action :commit, only: [:show]
before_action :authorize_read_pipeline!
before_action :authorize_create_pipeline!, only: [:new, :create]
before_action :authorize_update_pipeline!, only: [:retry, :cancel]
- before_action :authorize_admin_pipeline!, only: [:settings, :update_settings]
def index
@scope = params[:scope]
@@ -44,36 +43,12 @@ class Projects::PipelinesController < Projects::ApplicationController
redirect_back_or_default default: namespace_project_pipelines_path(project.namespace, project)
end
- def settings
- @ref = params[:ref] || @project.default_branch || 'master'
- @build_badge = Gitlab::Badge::Build.new(@project, @ref)
- end
-
- def update_settings
- if @project.update_attributes(pipelines_settings_params)
- flash[:notice] = "CI/CD Pipelines settings for '#{@project.name}' was successfully updated."
- redirect_to(
- settings_namespace_project_pipelines_path(@project.namespace, @project),
- notice: "CI/CD Pipelines settings for '#{@project.name}' was successfully updated."
- )
- else
- render 'settings'
- end
- end
-
private
def create_params
params.require(:pipeline).permit(:ref)
end
- def pipelines_settings_params
- params.require(:project).permit(
- :runners_token, :builds_enabled, :build_allow_git_fetch, :build_timeout_in_minutes, :build_coverage_regex,
- :public_builds
- )
- end
-
def pipeline
@pipeline ||= project.pipelines.find_by!(id: params[:id])
end
diff --git a/app/controllers/projects/pipelines_settings_controller.rb b/app/controllers/projects/pipelines_settings_controller.rb
new file mode 100644
index 00000000000..e7b96887c9c
--- /dev/null
+++ b/app/controllers/projects/pipelines_settings_controller.rb
@@ -0,0 +1,33 @@
+class Projects::PipelinesSettingsController < Projects::ApplicationController
+ before_action :authorize_admin_pipeline!
+
+ def show
+ @ref = params[:ref] || @project.default_branch || 'master'
+ @build_badge = Gitlab::Badge::Build.new(@project, @ref)
+ end
+
+ def update
+ if @project.update_attributes(update_params)
+ flash[:notice] = "CI/CD Pipelines settings for '#{@project.name}' was successfully updated."
+ redirect_to(
+ namespace_project_pipelines_settings_path(@project.namespace, @project),
+ notice: "CI/CD Pipelines settings for '#{@project.name}' was successfully updated."
+ )
+ else
+ render 'index'
+ end
+ end
+
+ private
+
+ def create_params
+ params.require(:pipeline).permit(:ref)
+ end
+
+ def update_params
+ params.require(:project).permit(
+ :runners_token, :builds_enabled, :build_allow_git_fetch, :build_timeout_in_minutes, :build_coverage_regex,
+ :public_builds
+ )
+ end
+end
diff --git a/app/controllers/projects/refs_controller.rb b/app/controllers/projects/refs_controller.rb
index 08d74634315..3602b3d5e58 100644
--- a/app/controllers/projects/refs_controller.rb
+++ b/app/controllers/projects/refs_controller.rb
@@ -25,7 +25,7 @@ class Projects::RefsController < Projects::ApplicationController
when "graphs_commits"
commits_namespace_project_graph_path(@project.namespace, @project, @id)
when "badges"
- settings_namespace_project_pipelines_path(@project.namespace, @project, ref: @id)
+ namespace_project_pipelines_settings_path(@project.namespace, @project, ref: @id)
else
namespace_project_commits_path(@project.namespace, @project, @id)
end
diff --git a/app/views/layouts/nav/_project_settings.html.haml b/app/views/layouts/nav/_project_settings.html.haml
index ca7b502eb5a..52a5bdc1a1b 100644
--- a/app/views/layouts/nav/_project_settings.html.haml
+++ b/app/views/layouts/nav/_project_settings.html.haml
@@ -39,7 +39,7 @@
= link_to namespace_project_triggers_path(@project.namespace, @project), title: 'Triggers' do
%span
Triggers
- = nav_link(controller: :pipelines) do
- = link_to settings_namespace_project_pipelines_path(@project.namespace, @project), title: 'CI/CD Pipelines' do
+ = nav_link(controller: :pipelines_settings) do
+ = link_to namespace_project_pipelines_settings_path(@project.namespace, @project), title: 'CI/CD Pipelines' do
%span
CI/CD Pipelines
diff --git a/app/views/projects/pipelines/settings.html.haml b/app/views/projects/pipelines_settings/show.html.haml
index 8c90defc2be..228bad36ebd 100644
--- a/app/views/projects/pipelines/settings.html.haml
+++ b/app/views/projects/pipelines_settings/show.html.haml
@@ -7,7 +7,7 @@
.col-lg-9
%h5.prepend-top-0
Pipelines
- = form_for @project, url: settings_namespace_project_pipelines_path(@project.namespace.becomes(Namespace), @project), remote: true, authenticity_token: true do |f|
+ = form_for @project, url: namespace_project_pipelines_settings_path(@project.namespace.becomes(Namespace), @project), remote: true, authenticity_token: true do |f|
%fieldset.builds-feature
- unless @repository.gitlab_ci_yml
.form-group
diff --git a/config/routes.rb b/config/routes.rb
index 57f1e1428e1..21f3585bacd 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -732,7 +732,9 @@ Rails.application.routes.draw do
resources :triggers, only: [:index, :create, :destroy]
resources :pipelines, only: [:index, :new, :create, :show] do
- resource :settings, only: [:index, :update]
+ collection do
+ resource :pipelines_settings, path: 'settings', only: [:show, :update]
+ end
member do
post :cancel
diff --git a/spec/features/pipelines_settings_spec.rb b/spec/features/pipelines_settings_spec.rb
new file mode 100644
index 00000000000..dcc364a3d01
--- /dev/null
+++ b/spec/features/pipelines_settings_spec.rb
@@ -0,0 +1,35 @@
+require 'spec_helper'
+
+feature "Pipelines settings", feature: true do
+ include GitlabRoutingHelper
+
+ let(:project) { create(:empty_project) }
+ let(:user) { create(:user) }
+ let(:role) { :developer }
+
+ background do
+ login_as(user)
+ project.team << [user, role]
+ visit namespace_project_pipelines_settings_path(project.namespace, project)
+ end
+
+ context 'for developer' do
+ given(:role) { :developer }
+
+ scenario 'to be disallowed to view' do
+ expect(page.status_code).to eq(404)
+ end
+ end
+
+ context 'for master' do
+ given(:role) { :master }
+
+ scenario 'be allowed to change' do
+ fill_in('Test coverage parsing', with: 'coverage_regex')
+ click_on 'Save changes'
+
+ expect(page.status_code).to eq(200)
+ expect(page).to have_field('Test coverage parsing', with: 'coverage_regex')
+ end
+ end
+end
diff --git a/spec/features/pipelines_spec.rb b/spec/features/pipelines_spec.rb
index 100f1015a32..7f861db1969 100644
--- a/spec/features/pipelines_spec.rb
+++ b/spec/features/pipelines_spec.rb
@@ -1,15 +1,14 @@
require 'spec_helper'
-feature "Pipelines", feature: true do
+describe "Pipelines" do
include GitlabRoutingHelper
let(:project) { create(:empty_project) }
let(:user) { create(:user) }
- let(:role) { :developer }
before do
login_as(user)
- project.team << [user, role]
+ project.team << [user, :developer]
end
describe 'GET /:project/pipelines' do
@@ -209,30 +208,4 @@ feature "Pipelines", feature: true do
it { expect(page).to have_content('Reference not found') }
end
end
-
- describe 'Pipelines settings' do
- background do
- visit settings_namespace_project_pipelines_path(project.namespace, project)
- end
-
- context 'for developer' do
- given(:role) { :developer }
-
- scenario 'to be disallowed to view' do
- expect(page.status_code).to eq(404)
- end
- end
-
- context 'for master' do
- given(:role) { :master }
-
- scenario 'be allowed to change' do
- fill_in('Test coverage parsing', with: 'coverage_regex')
- click_on 'Save changes'
-
- expect(page.status_code).to eq(200)
- expect(page).to have_field('Test coverage parsing', with: 'coverage_regex')
- end
- end
- end
end
diff --git a/spec/features/projects/badges/list_spec.rb b/spec/features/projects/badges/list_spec.rb
index d29fb265f91..75166bca119 100644
--- a/spec/features/projects/badges/list_spec.rb
+++ b/spec/features/projects/badges/list_spec.rb
@@ -6,7 +6,7 @@ feature 'list of badges' do
project = create(:project)
project.team << [user, :master]
login_as(user)
- visit settings_namespace_project_pipelines_path(project.namespace, project)
+ visit namespace_project_pipelines_settings_path(project.namespace, project)
end
scenario 'user displays list of badges' do