Add controllers spec
This commit is contained in:
parent
af86d33653
commit
4fa4a2ce99
|
@ -0,0 +1,30 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Projects::BuildsController do
|
||||||
|
include ApiHelpers
|
||||||
|
|
||||||
|
let(:user) { create(:user) }
|
||||||
|
let(:project) { create(:empty_project, :public) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
sign_in(user)
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'GET status.json' do
|
||||||
|
context 'when accessing status' do
|
||||||
|
before do
|
||||||
|
pipeline = create(:ci_pipeline, project: project)
|
||||||
|
build = create(:ci_build, pipeline: pipeline, status: 'success')
|
||||||
|
get :status, namespace_id: project.namespace,
|
||||||
|
project_id: project,
|
||||||
|
id: build.id,
|
||||||
|
format: :json
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns pipeline status via BuildSerializer' do
|
||||||
|
expect(response).to have_http_status(:ok)
|
||||||
|
expect(json_response['details']['status']['text']).to eq 'passed'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1178,4 +1178,24 @@ describe Projects::MergeRequestsController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'GET status.json' do
|
||||||
|
context 'when accessing status' do
|
||||||
|
before do
|
||||||
|
create(:ci_pipeline, project: merge_request.source_project,
|
||||||
|
ref: merge_request.source_branch,
|
||||||
|
sha: merge_request.diff_head_sha,
|
||||||
|
status: 'success')
|
||||||
|
get :status, namespace_id: project.namespace,
|
||||||
|
project_id: project,
|
||||||
|
id: merge_request.iid,
|
||||||
|
format: :json
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns pipeline status via PipelineSerializer' do
|
||||||
|
expect(response).to have_http_status(:ok)
|
||||||
|
expect(json_response['details']['status']['text']).to eq 'passed'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -69,4 +69,21 @@ describe Projects::PipelinesController do
|
||||||
format: :json
|
format: :json
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'GET status.json' do
|
||||||
|
context 'when accessing status' do
|
||||||
|
before do
|
||||||
|
pipeline = create(:ci_pipeline, project: project, status: 'success')
|
||||||
|
get :status, namespace_id: project.namespace,
|
||||||
|
project_id: project,
|
||||||
|
id: pipeline.id,
|
||||||
|
format: :json
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns pipeline status via PipelineSerializer' do
|
||||||
|
expect(response).to have_http_status(:ok)
|
||||||
|
expect(json_response['details']['status']['text']).to eq 'passed'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue