2016-12-20 09:53:53 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Projects::PipelinesController do
|
|
|
|
include ApiHelpers
|
|
|
|
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:empty_project, :public) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
2016-12-21 09:13:24 -05:00
|
|
|
describe 'GET index.json' do
|
|
|
|
before do
|
|
|
|
create_list(:ci_empty_pipeline, 2, project: project)
|
|
|
|
|
|
|
|
get :index, namespace_id: project.namespace.path,
|
|
|
|
project_id: project.path,
|
|
|
|
format: :json
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns JSON with serialized pipelines' do
|
|
|
|
expect(response).to have_http_status(:ok)
|
|
|
|
|
|
|
|
expect(json_response).to include('pipelines')
|
|
|
|
expect(json_response['pipelines'].count).to eq 2
|
|
|
|
expect(json_response['count']['all']).to eq 2
|
|
|
|
expect(json_response['count']['running_or_pending']).to eq 2
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-12-20 09:53:53 -05:00
|
|
|
describe 'GET stages.json' do
|
2016-12-21 09:13:24 -05:00
|
|
|
let(:pipeline) { create(:ci_pipeline, project: project) }
|
|
|
|
|
2016-12-20 09:53:53 -05:00
|
|
|
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
|
|
|
|
|
2016-12-20 14:07:34 -05:00
|
|
|
it 'responds with not found' do
|
|
|
|
expect(response).to have_http_status(:not_found)
|
|
|
|
end
|
2016-12-20 09:53:53 -05:00
|
|
|
end
|
|
|
|
|
2016-12-20 14:07:34 -05:00
|
|
|
def get_stage(name)
|
|
|
|
get :stage, namespace_id: project.namespace.path,
|
|
|
|
project_id: project.path,
|
|
|
|
id: pipeline.id,
|
|
|
|
stage: name,
|
|
|
|
format: :json
|
|
|
|
end
|
2016-12-20 09:53:53 -05:00
|
|
|
end
|
|
|
|
end
|