Commit 49fc5db1 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'mo-refactor-stages-controller' into 'master'

Inherit StagesController from Projects::Pipelines::ApplicationController

See merge request gitlab-org/gitlab!36586
parents 8b0417a6 4193baf2
# frozen_string_literal: true
module Projects
module Pipelines
class StagesController < Projects::Pipelines::ApplicationController
before_action :authorize_update_pipeline!
def play_manual
::Ci::PlayManualStageService
.new(@project, current_user, pipeline: pipeline)
.execute(stage)
respond_to do |format|
format.json do
render json: StageSerializer
.new(project: @project, current_user: @current_user)
.represent(stage)
end
end
end
private
def stage
@pipeline_stage ||= pipeline.find_stage_by_name!(params[:stage_name])
end
end
end
end
# frozen_string_literal: true
class Projects::StagesController < Projects::PipelinesController
before_action :authorize_update_pipeline!
def play_manual
::Ci::PlayManualStageService
.new(@project, current_user, pipeline: pipeline)
.execute(stage)
respond_to do |format|
format.json do
render json: StageSerializer
.new(project: @project, current_user: @current_user)
.represent(stage)
end
end
end
private
def stage
@pipeline_stage ||= pipeline.find_stage_by_name!(params[:stage_name])
end
end
......@@ -22,10 +22,8 @@ resources :pipelines, only: [:index, :new, :create, :show, :destroy] do
get :test_reports_count
end
member do
resources :stages, only: [], param: :name do
post :play_manual
end
resources :stages, only: [], param: :name, controller: 'pipelines/stages' do
post :play_manual
end
resources :tests, only: [:show], param: :suite_name, controller: 'pipelines/tests' do
......
......@@ -18,7 +18,7 @@ module Gitlab
def action_path
pipeline = subject.pipeline
project_stage_play_manual_path(pipeline.project, pipeline, subject.name)
project_pipeline_stage_play_manual_path(pipeline.project, pipeline, subject.name)
end
def action_method
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Projects::StagesController do
RSpec.describe Projects::Pipelines::StagesController do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
......@@ -60,7 +60,7 @@ RSpec.describe Projects::StagesController do
post :play_manual, params: {
namespace_id: project.namespace,
project_id: project,
id: pipeline.id,
pipeline_id: pipeline.id,
stage_name: stage_name
}, format: :json
end
......
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