diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2017-06-05 13:24:57 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2017-06-05 13:24:57 +0300 |
commit | 9ccb289aa10f26e418dec06c5d6cf70205560ff4 (patch) | |
tree | e4e6a8effef63d1a3143daa52cc91d6419d6a36e /spec/controllers | |
parent | 3cc5e48668caf97588241001866fd42666b2f8f0 (diff) | |
parent | 1709e5cf876cf92c939464a633ddc6858b506e4f (diff) |
Merge branch 'zj-job-view-goes-real-time' into 'master'
Initial implementation for real time job view
Closes #31397
See merge request !11651
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/projects/jobs_controller_spec.rb | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb index 838bdae1445..7211acc53dc 100644 --- a/spec/controllers/projects/jobs_controller_spec.rb +++ b/spec/controllers/projects/jobs_controller_spec.rb @@ -101,26 +101,49 @@ describe Projects::JobsController do end describe 'GET show' do - context 'when build exists' do - let!(:build) { create(:ci_build, pipeline: pipeline) } + let!(:build) { create(:ci_build, :failed, pipeline: pipeline) } - before do - get_show(id: build.id) + context 'when requesting HTML' do + context 'when build exists' do + before do + get_show(id: build.id) + end + + it 'has a build' do + expect(response).to have_http_status(:ok) + expect(assigns(:build).id).to eq(build.id) + end end - it 'has a build' do - expect(response).to have_http_status(:ok) - expect(assigns(:build).id).to eq(build.id) + context 'when build does not exist' do + before do + get_show(id: 1234) + end + + it 'renders not_found' do + expect(response).to have_http_status(:not_found) + end end end - context 'when build does not exist' do + context 'when requesting JSON' do + let(:merge_request) { create(:merge_request, source_project: project) } + before do - get_show(id: 1234) + project.add_developer(user) + sign_in(user) + + allow_any_instance_of(Ci::Build).to receive(:merge_request).and_return(merge_request) + + get_show(id: build.id, format: :json) end - it 'renders not_found' do - expect(response).to have_http_status(:not_found) + it 'exposes needed information' do + expect(response).to have_http_status(:ok) + expect(json_response['raw_path']).to match(/builds\/\d+\/raw\z/) + expect(json_response.dig('merge_request', 'path')).to match(/merge_requests\/\d+\z/) + expect(json_response['new_issue_path']) + .to include('/issues/new') end end |