diff options
author | Shinya Maeda <gitlab.shinyamaeda@gmail.com> | 2017-03-21 22:21:13 +0900 |
---|---|---|
committer | Shinya Maeda <gitlab.shinyamaeda@gmail.com> | 2017-03-23 17:11:49 +0900 |
commit | a375d80eb072d62962af9b6f2decf9782cd7ee1f (patch) | |
tree | 4cea31ebfcac1b9dcc42ea51a951588fcecc53ce /spec/controllers/projects/merge_requests_controller_spec.rb | |
parent | 6dcd2d591fa00be027b92e8c0e6b3b129921f4fa (diff) | |
download | gitlab-ce-a375d80eb072d62962af9b6f2decf9782cd7ee1f.tar.gz |
Use detailed_status effectively. Remove unnecesarry context(nest). Add new context in merge_requests_controller_spec.rb and fix a bug. Correct description of spec.
Diffstat (limited to 'spec/controllers/projects/merge_requests_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/merge_requests_controller_spec.rb | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb index 9fa509c339e..72f41f7209a 100644 --- a/spec/controllers/projects/merge_requests_controller_spec.rb +++ b/spec/controllers/projects/merge_requests_controller_spec.rb @@ -1180,23 +1180,18 @@ describe Projects::MergeRequestsController do end describe 'GET pipeline_status.json' do - context 'when accessing pipeline_status' do - let(:status) do - Gitlab::Ci::Status::Success.new(double('object'), double('user')) - end - - before do + context 'when head_pipeline exists' do + let!(:pipeline) do create(:ci_pipeline, project: merge_request.source_project, ref: merge_request.source_branch, - sha: merge_request.diff_head_sha, - status: :success) - get :pipeline_status, namespace_id: project.namespace, - project_id: project, - id: merge_request.iid, - format: :json + sha: merge_request.diff_head_sha) end - it 'return a correct pipeline status' do + let(:status) { pipeline.detailed_status(double('user')) } + + before { get_pipeline_status } + + it 'return a detailed head_pipeline status in json' do expect(response).to have_http_status(:ok) expect(json_response['text']).to eq status.text expect(json_response['label']).to eq status.label @@ -1204,5 +1199,21 @@ describe Projects::MergeRequestsController do expect(json_response['favicon']).to eq status.favicon end end + + context 'when head_pipeline does not exist' do + before { get_pipeline_status } + + it 'return empty' do + expect(response).to have_http_status(:ok) + expect(json_response).to be_empty + end + end + + def get_pipeline_status + get :pipeline_status, namespace_id: project.namespace, + project_id: project, + id: merge_request.iid, + format: :json + end end end |