diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-12-07 19:14:20 +0300 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-12-07 19:17:30 +0300 |
commit | 5de224e3dc11ab9dafb291417797f1404f6f4be9 (patch) | |
tree | 6ea40e3925a0f6ef0c876887bbf9c35b0dafc390 /spec/controllers/projects | |
parent | c1a098c78bf270f222a6ae98db38c820dfc6ed72 (diff) |
Extract context in JobsController spec
Diffstat (limited to 'spec/controllers/projects')
-rw-r--r-- | spec/controllers/projects/jobs_controller_spec.rb | 78 |
1 files changed, 40 insertions, 38 deletions
diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb index cb622e2736b..bd193979192 100644 --- a/spec/controllers/projects/jobs_controller_spec.rb +++ b/spec/controllers/projects/jobs_controller_spec.rb @@ -398,57 +398,59 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do end end - context 'with variables and user is a maintainer' do + context 'with variables' do before do - project.add_maintainer(user) - create(:ci_pipeline_variable, pipeline: pipeline, key: :TRIGGER_KEY_1, value: 'TRIGGER_VALUE_1') - - get_show(id: job.id, format: :json) - - @first_variable = json_response['trigger']['variables'].first end - it 'returns a job_detail' do - expect(response).to have_gitlab_http_status(:ok) - expect(response).to match_response_schema('job/job_details') - end + context 'user is a maintainer' do + before do + project.add_maintainer(user) - it 'exposes trigger information and variables' do - expect(json_response['trigger']['short_token']).to eq 'toke' - expect(json_response['trigger']['variables'].length).to eq 1 - end + get_show(id: job.id, format: :json) + end - it 'exposes correct variable properties' do - expect(@first_variable['key']).to eq "TRIGGER_KEY_1" - expect(@first_variable['value']).to eq "TRIGGER_VALUE_1" - expect(@first_variable['public']).to eq false - end - end + it 'returns a job_detail' do + expect(response).to have_gitlab_http_status(:ok) + expect(response).to match_response_schema('job/job_details') + end - context 'with variables and user is not a mantainer' do - before do - create(:ci_pipeline_variable, pipeline: pipeline, key: :TRIGGER_KEY_1, value: 'TRIGGER_VALUE_1') + it 'exposes trigger information and variables' do + expect(json_response['trigger']['short_token']).to eq 'toke' + expect(json_response['trigger']['variables'].length).to eq 1 + end - get_show(id: job.id, format: :json) + it 'exposes correct variable properties' do + first_variable = json_response['trigger']['variables'].first - @first_variable = json_response['trigger']['variables'].first + expect(first_variable['key']).to eq "TRIGGER_KEY_1" + expect(first_variable['value']).to eq "TRIGGER_VALUE_1" + expect(first_variable['public']).to eq false + end end - it 'returns a job_detail' do - expect(response).to have_gitlab_http_status(:ok) - expect(response).to match_response_schema('job/job_details') - end + context 'user is not a mantainer' do + before do + get_show(id: job.id, format: :json) + end - it 'exposes trigger information and variables' do - expect(json_response['trigger']['short_token']).to eq 'toke' - expect(json_response['trigger']['variables'].length).to eq 1 - end + it 'returns a job_detail' do + expect(response).to have_gitlab_http_status(:ok) + expect(response).to match_response_schema('job/job_details') + end - it 'exposes correct variable properties' do - expect(@first_variable['key']).to eq "TRIGGER_KEY_1" - expect(@first_variable['value']).to be_nil - expect(@first_variable['public']).to eq false + it 'exposes trigger information and variables' do + expect(json_response['trigger']['short_token']).to eq 'toke' + expect(json_response['trigger']['variables'].length).to eq 1 + end + + it 'exposes correct variable properties' do + first_variable = json_response['trigger']['variables'].first + + expect(first_variable['key']).to eq "TRIGGER_KEY_1" + expect(first_variable['value']).to be_nil + expect(first_variable['public']).to eq false + end end end end |