Commit 4fa4a2ce authored by Shinya Maeda's avatar Shinya Maeda

Add controllers spec

parent af86d336
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 ...@@ -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 ...@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment