Commit 8ffe586b authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Changed the controller/route name to 'ci/cd' and renamed the corresponding files

Added tests to verify the access policy to the new controller
parent 085d5eae
...@@ -2,13 +2,13 @@ class Projects::PipelinesSettingsController < Projects::ApplicationController ...@@ -2,13 +2,13 @@ class Projects::PipelinesSettingsController < Projects::ApplicationController
before_action :authorize_admin_pipeline! before_action :authorize_admin_pipeline!
def show def show
redirect_to namespace_project_settings_ci_cd_pipelines_path(@project.namespace, @project, params: params) redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @project, params: params)
end end
def update def update
if @project.update_attributes(update_params) if @project.update_attributes(update_params)
flash[:notice] = "CI/CD Pipelines settings for '#{@project.name}' were successfully updated." flash[:notice] = "CI/CD Pipelines settings for '#{@project.name}' were successfully updated."
redirect_to namespace_project_settings_ci_cd_pipelines_path(@project.namespace, @project) redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @project)
else else
render 'show' render 'show'
end end
......
...@@ -4,10 +4,6 @@ class Projects::RunnersController < Projects::ApplicationController ...@@ -4,10 +4,6 @@ class Projects::RunnersController < Projects::ApplicationController
layout 'project_settings' layout 'project_settings'
def index
redirect_to namespace_project_settings_ci_cd_pipelines_path(@project.namespace, @project)
end
def edit def edit
end end
...@@ -49,7 +45,7 @@ class Projects::RunnersController < Projects::ApplicationController ...@@ -49,7 +45,7 @@ class Projects::RunnersController < Projects::ApplicationController
def toggle_shared_runners def toggle_shared_runners
project.toggle!(:shared_runners_enabled) project.toggle!(:shared_runners_enabled)
redirect_to namespace_project_settings_ci_cd_pipelines_path(@project.namespace, @project) redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @project)
end end
protected protected
......
module Projects module Projects
module Settings module Settings
class CiCdPipelinesController < Projects::ApplicationController class CiCdController < Projects::ApplicationController
before_action :authorize_admin_pipeline! before_action :authorize_admin_pipeline!
def show def show
define_runners_variables define_runners_variables
# variables define_project_variables_variables
@variable = Ci::Variable.new
define_triggers_variables define_triggers_variables
define_badges_variables define_badges_variables
end end
...@@ -21,6 +20,10 @@ module Projects ...@@ -21,6 +20,10 @@ module Projects
@shared_runners_count = @shared_runners.count(:all) @shared_runners_count = @shared_runners.count(:all)
end end
def define_project_variables_variables
@variable = Ci::Variable.new
end
def define_triggers_variables def define_triggers_variables
@triggers = @project.triggers @triggers = @project.triggers
@trigger = Ci::Trigger.new @trigger = Ci::Trigger.new
......
...@@ -3,16 +3,12 @@ class Projects::TriggersController < Projects::ApplicationController ...@@ -3,16 +3,12 @@ class Projects::TriggersController < Projects::ApplicationController
layout 'project_settings' layout 'project_settings'
def index
redirect_to namespace_project_settings_ci_cd_pipelines_path(@project.namespace, @project)
end
def create def create
@trigger = project.triggers.new @trigger = project.triggers.new
@trigger.save @trigger.save
if @trigger.valid? if @trigger.valid?
redirect_to namespace_project_settings_ci_cd_pipelines_path(@project.namespace, @project) redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @project)
else else
@triggers = project.triggers.select(&:persisted?) @triggers = project.triggers.select(&:persisted?)
render :index render :index
...@@ -22,7 +18,7 @@ class Projects::TriggersController < Projects::ApplicationController ...@@ -22,7 +18,7 @@ class Projects::TriggersController < Projects::ApplicationController
def destroy def destroy
trigger.destroy trigger.destroy
redirect_to namespace_project_settings_ci_cd_pipelines_path(@project.namespace, @project) redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @project)
end end
private private
......
...@@ -3,10 +3,6 @@ class Projects::VariablesController < Projects::ApplicationController ...@@ -3,10 +3,6 @@ class Projects::VariablesController < Projects::ApplicationController
layout 'project_settings' layout 'project_settings'
def index
redirect_to namespace_project_settings_ci_cd_pipelines_path(project.namespace, project)
end
def show def show
@variable = @project.variables.find(params[:id]) @variable = @project.variables.find(params[:id])
end end
...@@ -15,7 +11,7 @@ class Projects::VariablesController < Projects::ApplicationController ...@@ -15,7 +11,7 @@ class Projects::VariablesController < Projects::ApplicationController
@variable = @project.variables.find(params[:id]) @variable = @project.variables.find(params[:id])
if @variable.update_attributes(project_params) if @variable.update_attributes(project_params)
redirect_to namespace_project_settings_ci_cd_pipelines_path(project.namespace, project), notice: 'Variable was successfully updated.' redirect_to namespace_project_settings_ci_cd_path(project.namespace, project), notice: 'Variable was successfully updated.'
else else
render action: "show" render action: "show"
end end
...@@ -25,7 +21,7 @@ class Projects::VariablesController < Projects::ApplicationController ...@@ -25,7 +21,7 @@ class Projects::VariablesController < Projects::ApplicationController
@variable = Ci::Variable.new(project_params) @variable = Ci::Variable.new(project_params)
if @variable.valid? && @project.variables << @variable if @variable.valid? && @project.variables << @variable
redirect_to namespace_project_settings_ci_cd_pipelines_path(project.namespace, project), notice: 'Variables were successfully updated.' redirect_to namespace_project_settings_ci_cd_path(project.namespace, project), notice: 'Variables were successfully updated.'
else else
render action: "index" render action: "index"
end end
...@@ -35,7 +31,7 @@ class Projects::VariablesController < Projects::ApplicationController ...@@ -35,7 +31,7 @@ class Projects::VariablesController < Projects::ApplicationController
@key = @project.variables.find(params[:id]) @key = @project.variables.find(params[:id])
@key.destroy @key.destroy
redirect_to namespace_project_settings_ci_cd_pipelines_path(project.namespace, project), notice: 'Variable was successfully removed.' redirect_to namespace_project_settings_ci_cd_path(project.namespace, project), notice: 'Variable was successfully removed.'
end end
private private
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
Protected Branches Protected Branches
- if @project.feature_available?(:builds, current_user) - if @project.feature_available?(:builds, current_user)
= nav_link(controller: :ci_cd_pipelines_settings) do = nav_link(controller: :ci_cd) do
= link_to namespace_project_settings_ci_cd_pipelines_path(@project.namespace, @project), title: 'CI/CD Pipelines' do = link_to namespace_project_settings_ci_cd_path(@project.namespace, @project), title: 'CI/CD Pipelines' do
%span %span
CI/CD Pipelines CI/CD Pipelines
= nav_link(controller: :pages) do = nav_link(controller: :pages) do
......
...@@ -315,7 +315,7 @@ constraints(ProjectUrlConstrainer.new) do ...@@ -315,7 +315,7 @@ constraints(ProjectUrlConstrainer.new) do
end end
namespace :settings do namespace :settings do
resource :members, only: [:show] resource :members, only: [:show]
resource :ci_cd_pipelines, only: [:show] resource :ci_cd, only: [:show], controller: 'ci_cd'
resource :integrations, only: [:show] resource :integrations, only: [:show]
end end
......
...@@ -96,6 +96,20 @@ describe "Internal Project Access", feature: true do ...@@ -96,6 +96,20 @@ describe "Internal Project Access", feature: true do
it { is_expected.to be_denied_for(:external) } it { is_expected.to be_denied_for(:external) }
end end
describe "GET /:project_path/settings/ci_cd" do
subject { namespace_project_settings_ci_cd_path(project.namespace, project) }
it { is_expected.to be_allowed_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:master).of(project) }
it { is_expected.to be_denied_for(:developer).of(project) }
it { is_expected.to be_denied_for(:reporter).of(project) }
it { is_expected.to be_denied_for(:guest).of(project) }
it { is_expected.to be_denied_for(:user) }
it { is_expected.to be_denied_for(:visitor) }
it { is_expected.to be_denied_for(:external) }
end
describe "GET /:project_path/blob" do describe "GET /:project_path/blob" do
let(:commit) { project.repository.commit } let(:commit) { project.repository.commit }
subject { namespace_project_blob_path(project.namespace, project, File.join(commit.id, '.gitignore')) } subject { namespace_project_blob_path(project.namespace, project, File.join(commit.id, '.gitignore')) }
......
...@@ -82,18 +82,18 @@ describe "Private Project Access", feature: true do ...@@ -82,18 +82,18 @@ describe "Private Project Access", feature: true do
it { is_expected.to be_denied_for(:visitor) } it { is_expected.to be_denied_for(:visitor) }
end end
describe "GET /:project_path/settings/members" do describe "GET /:project_path/settings/ci_cd" do
subject { namespace_project_settings_members_path(project.namespace, project) } subject { namespace_project_settings_ci_cd_path(project.namespace, project) }
it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:master).of(project) } it { is_expected.to be_allowed_for(:master).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) }
it { is_expected.to be_allowed_for(:reporter).of(project) } it { is_expected.to be_denied_for(:reporter).of(project) }
it { is_expected.to be_allowed_for(:guest).of(project) } it { is_expected.to be_denied_for(:guest).of(project) }
it { is_expected.to be_denied_for(:user) } it { is_expected.to be_denied_for(:user) }
it { is_expected.to be_denied_for(:external) }
it { is_expected.to be_denied_for(:visitor) } it { is_expected.to be_denied_for(:visitor) }
it { is_expected.to be_denied_for(:external) }
end end
describe "GET /:project_path/blob" do describe "GET /:project_path/blob" do
......
...@@ -96,6 +96,20 @@ describe "Public Project Access", feature: true do ...@@ -96,6 +96,20 @@ describe "Public Project Access", feature: true do
it { is_expected.to be_allowed_for(:external) } it { is_expected.to be_allowed_for(:external) }
end end
describe "GET /:project_path/settings/ci_cd" do
subject { namespace_project_settings_ci_cd_path(project.namespace, project) }
it { is_expected.to be_allowed_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:master).of(project) }
it { is_expected.to be_denied_for(:developer).of(project) }
it { is_expected.to be_denied_for(:reporter).of(project) }
it { is_expected.to be_denied_for(:guest).of(project) }
it { is_expected.to be_denied_for(:user) }
it { is_expected.to be_denied_for(:visitor) }
it { is_expected.to be_denied_for(:external) }
end
describe "GET /:project_path/pipelines" do describe "GET /:project_path/pipelines" do
subject { namespace_project_pipelines_path(project.namespace, project) } subject { namespace_project_pipelines_path(project.namespace, project) }
......
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