diff options
Diffstat (limited to 'spec/controllers/projects/jobs_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/jobs_controller_spec.rb | 94 |
1 files changed, 76 insertions, 18 deletions
diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb index 94cce1964ca..80cb16966e5 100644 --- a/spec/controllers/projects/jobs_controller_spec.rb +++ b/spec/controllers/projects/jobs_controller_spec.rb @@ -121,13 +121,6 @@ RSpec.describe Projects::JobsController, :clean_gitlab_redis_shared_state do expect(response).to have_gitlab_http_status(:ok) expect(assigns(:build).id).to eq(job.id) end - - it 'has the correct build collection' do - builds = assigns(:builds).map(&:id) - - expect(builds).to include(job.id, second_job.id) - expect(builds).not_to include(third_job.id) - end end context 'when job does not exist' do @@ -204,16 +197,40 @@ RSpec.describe Projects::JobsController, :clean_gitlab_redis_shared_state do context 'with not expiry date' do let(:job) { create(:ci_build, :success, :artifacts, pipeline: pipeline) } - it 'exposes needed information' do - get_show_json + context 'when artifacts are unlocked' do + before do + job.pipeline.unlocked! + end - expect(response).to have_gitlab_http_status(:ok) - expect(response).to match_response_schema('job/job_details') - expect(json_response['artifact']['download_path']).to match(%r{artifacts/download}) - expect(json_response['artifact']['browse_path']).to match(%r{artifacts/browse}) - expect(json_response['artifact']).not_to have_key('keep_path') - expect(json_response['artifact']).not_to have_key('expired') - expect(json_response['artifact']).not_to have_key('expired_at') + it 'exposes needed information' do + get_show_json + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to match_response_schema('job/job_details') + expect(json_response['artifact']['download_path']).to match(%r{artifacts/download}) + expect(json_response['artifact']['browse_path']).to match(%r{artifacts/browse}) + expect(json_response['artifact']).not_to have_key('keep_path') + expect(json_response['artifact']).not_to have_key('expired') + expect(json_response['artifact']).not_to have_key('expired_at') + end + end + + context 'when artifacts are locked' do + before do + job.pipeline.artifacts_locked! + end + + it 'exposes needed information' do + get_show_json + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to match_response_schema('job/job_details') + expect(json_response['artifact']['download_path']).to match(%r{artifacts/download}) + expect(json_response['artifact']['browse_path']).to match(%r{artifacts/browse}) + expect(json_response['artifact']).not_to have_key('keep_path') + expect(json_response['artifact']).not_to have_key('expired') + expect(json_response['artifact']).not_to have_key('expired_at') + end end end @@ -740,19 +757,21 @@ RSpec.describe Projects::JobsController, :clean_gitlab_redis_shared_state do name: 'master', project: project) sign_in(user) - - post_play end context 'when job is playable' do let(:job) { create(:ci_build, :playable, pipeline: pipeline) } it 'redirects to the played job page' do + post_play + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(namespace_project_job_path(id: job.id)) end it 'transits to pending' do + post_play + expect(job.reload).to be_pending end @@ -760,15 +779,54 @@ RSpec.describe Projects::JobsController, :clean_gitlab_redis_shared_state do let(:variable_attributes) { [{ key: 'first', secret_value: 'first' }] } it 'assigns the job variables' do + post_play + expect(job.reload.job_variables.map(&:key)).to contain_exactly('first') end end + + context 'when job is bridge' do + let(:downstream_project) { create(:project) } + let(:job) { create(:ci_bridge, :playable, pipeline: pipeline, downstream: downstream_project) } + + before do + downstream_project.add_developer(user) + end + + it 'redirects to the pipeline page' do + post_play + + expect(response).to have_gitlab_http_status(:found) + expect(response).to redirect_to(pipeline_path(pipeline)) + builds_namespace_project_pipeline_path(id: pipeline.id) + end + + it 'transits to pending' do + post_play + + expect(job.reload).to be_pending + end + + context 'when FF ci_manual_bridges is disabled' do + before do + stub_feature_flags(ci_manual_bridges: false) + end + + it 'returns 404' do + post_play + + expect(response).to have_gitlab_http_status(:not_found) + end + end + end end context 'when job is not playable' do let(:job) { create(:ci_build, pipeline: pipeline) } it 'renders unprocessable_entity' do + post_play + expect(response).to have_gitlab_http_status(:unprocessable_entity) end end |