Add stages_ajax endpoint to serve old HTML
This commit is contained in:
parent
f7dccbb7dd
commit
6ea31cb7cd
4 changed files with 48 additions and 3 deletions
|
@ -109,6 +109,15 @@ class Projects::PipelinesController < Projects::ApplicationController
|
||||||
.represent(@stage, details: true)
|
.represent(@stage, details: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO: This endpoint is used by mini-pipeline-graph
|
||||||
|
# TODO: This endpoint should be migrated to `stage.json`
|
||||||
|
def stage_ajax
|
||||||
|
@stage = pipeline.legacy_stage(params[:stage])
|
||||||
|
return not_found unless @stage
|
||||||
|
|
||||||
|
render json: { html: view_to_html_string('projects/pipelines/_stage')) }
|
||||||
|
end
|
||||||
|
|
||||||
def retry
|
def retry
|
||||||
pipeline.retry_failed(current_user)
|
pipeline.retry_failed(current_user)
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
- status_klass = "ci-status-icon ci-status-icon-#{detailed_status.group}"
|
- status_klass = "ci-status-icon ci-status-icon-#{detailed_status.group}"
|
||||||
|
|
||||||
.stage-container.dropdown{ class: klass }
|
.stage-container.dropdown{ class: klass }
|
||||||
%button.mini-pipeline-graph-dropdown-toggle.has-tooltip.js-builds-dropdown-button{ class: "ci-status-icon-#{detailed_status.group}", type: 'button', data: { toggle: 'dropdown', title: "#{stage.name}: #{detailed_status.label}", placement: 'top', "stage-endpoint" => stage_project_pipeline_path(pipeline.project, pipeline, stage: stage.name) } }
|
%button.mini-pipeline-graph-dropdown-toggle.has-tooltip.js-builds-dropdown-button{ class: "ci-status-icon-#{detailed_status.group}", type: 'button', data: { toggle: 'dropdown', title: "#{stage.name}: #{detailed_status.label}", placement: 'top', "stage-endpoint" => stage_ajax_project_pipeline_path(pipeline.project, pipeline, stage: stage.name) } }
|
||||||
= sprite_icon(icon_status)
|
= sprite_icon(icon_status)
|
||||||
= icon('caret-down')
|
= icon('caret-down')
|
||||||
|
|
||||||
|
|
|
@ -183,6 +183,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
|
||||||
|
|
||||||
member do
|
member do
|
||||||
get :stage
|
get :stage
|
||||||
|
get :stage_ajax
|
||||||
post :cancel
|
post :cancel
|
||||||
post :retry
|
post :retry
|
||||||
get :builds
|
get :builds
|
||||||
|
|
|
@ -109,8 +109,7 @@ describe Projects::PipelinesController do
|
||||||
|
|
||||||
it 'returns html source for stage dropdown' do
|
it 'returns html source for stage dropdown' do
|
||||||
expect(response).to have_gitlab_http_status(:ok)
|
expect(response).to have_gitlab_http_status(:ok)
|
||||||
expect(response).to render_template('projects/pipelines/_stage')
|
expect(response).to match_response_schema('pipeline_stage')
|
||||||
expect(json_response).to include('html')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -133,6 +132,42 @@ describe Projects::PipelinesController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'GET stages_ajax.json' do
|
||||||
|
let(:pipeline) { create(:ci_pipeline, project: project) }
|
||||||
|
|
||||||
|
context 'when accessing existing stage' do
|
||||||
|
before do
|
||||||
|
create(:ci_build, pipeline: pipeline, stage: 'build')
|
||||||
|
|
||||||
|
get_stage_ajax('build')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns html source for stage dropdown' do
|
||||||
|
expect(response).to have_gitlab_http_status(:ok)
|
||||||
|
expect(response).to render_template('projects/pipelines/_stage')
|
||||||
|
expect(json_response).to include('html')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when accessing unknown stage' do
|
||||||
|
before do
|
||||||
|
get_stage_ajax('test')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'responds with not found' do
|
||||||
|
expect(response).to have_gitlab_http_status(:not_found)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_stage_ajax(name)
|
||||||
|
get :stage_ajax, namespace_id: project.namespace,
|
||||||
|
project_id: project,
|
||||||
|
id: pipeline.id,
|
||||||
|
stage: name,
|
||||||
|
format: :json
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'GET status.json' do
|
describe 'GET status.json' do
|
||||||
let(:pipeline) { create(:ci_pipeline, project: project) }
|
let(:pipeline) { create(:ci_pipeline, project: project) }
|
||||||
let(:status) { pipeline.detailed_status(double('user')) }
|
let(:status) { pipeline.detailed_status(double('user')) }
|
||||||
|
|
Loading…
Reference in a new issue