Add controllers spec

This commit is contained in:
Shinya Maeda 2017-03-06 21:01:18 +09:00
parent af86d33653
commit 4fa4a2ce99
3 changed files with 67 additions and 0 deletions

View File

@ -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

View File

@ -1178,4 +1178,24 @@ describe Projects::MergeRequestsController do
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

View File

@ -69,4 +69,21 @@ describe Projects::PipelinesController do
format: :json
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