Move test for HTML stage endpoint to controller specs
This commit is contained in:
parent
b2daf9f168
commit
9c6480db89
3 changed files with 47 additions and 33 deletions
46
spec/controllers/projects/pipelines_controller_spec.rb
Normal file
46
spec/controllers/projects/pipelines_controller_spec.rb
Normal file
|
@ -0,0 +1,46 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Projects::PipelinesController do
|
||||
include ApiHelpers
|
||||
|
||||
let(:user) { create(:user) }
|
||||
let(:project) { create(:empty_project, :public) }
|
||||
let(:pipeline) { create(:ci_pipeline, project: project) }
|
||||
|
||||
before do
|
||||
sign_in(user)
|
||||
end
|
||||
|
||||
describe 'GET stages.json' do
|
||||
def get_stage(name)
|
||||
get :stage, namespace_id: project.namespace.path,
|
||||
project_id: project.path,
|
||||
id: pipeline.id,
|
||||
stage: name,
|
||||
format: :json
|
||||
end
|
||||
|
||||
context 'when accessing existing stage' do
|
||||
before do
|
||||
create(:ci_build, pipeline: pipeline, stage: 'build')
|
||||
|
||||
get_stage('build')
|
||||
end
|
||||
|
||||
it 'returns html source for stage dropdown' do
|
||||
expect(response).to have_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('test')
|
||||
end
|
||||
|
||||
it { expect(response).to have_http_status(:not_found) }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe "Pipelines", feature: true, js: true do
|
||||
describe 'Pipeline', :feature, :js do
|
||||
include GitlabRoutingHelper
|
||||
|
||||
let(:project) { create(:empty_project) }
|
||||
|
|
|
@ -199,38 +199,6 @@ describe "Pipelines", feature: true, js:true do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'GET /:project/pipelines/stage.json?name=stage' do
|
||||
let!(:pipeline) do
|
||||
create(:ci_empty_pipeline, project: project, ref: 'master',
|
||||
status: 'running')
|
||||
end
|
||||
|
||||
context 'when accessing existing stage' do
|
||||
let!(:build) do
|
||||
create(:ci_build, pipeline: pipeline, stage: 'build')
|
||||
end
|
||||
|
||||
before do
|
||||
visit stage_namespace_project_pipeline_path(
|
||||
project.namespace, project, pipeline, format: :json, stage: 'build')
|
||||
end
|
||||
|
||||
it do
|
||||
expect(page).to have_http_status(:ok)
|
||||
expect(page.source).to include("html")
|
||||
end
|
||||
end
|
||||
|
||||
context 'when accessing unknown stage' do
|
||||
before do
|
||||
visit stage_namespace_project_pipeline_path(
|
||||
project.namespace, project, pipeline, format: :json, stage: 'test')
|
||||
end
|
||||
|
||||
it { expect(page).to have_http_status(:not_found) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST /:project/pipelines' do
|
||||
let(:project) { create(:project) }
|
||||
|
||||
|
|
Loading…
Reference in a new issue