Commit 7fd0f503 authored by Matija Čupić's avatar Matija Čupić

Extract context in JobsController spec

parent 6ad56a22
...@@ -398,15 +398,16 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do ...@@ -398,15 +398,16 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end end
end end
context 'with variables' do
before do
create(:ci_pipeline_variable, pipeline: pipeline, key: :TRIGGER_KEY_1, value: 'TRIGGER_VALUE_1')
end
context 'with variables and user is a maintainer' do context 'with variables and user is a maintainer' do
before do before do
project.add_maintainer(user) 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) get_show(id: job.id, format: :json)
@first_variable = json_response['trigger']['variables'].first
end end
it 'returns a job_detail' do it 'returns a job_detail' do
...@@ -420,19 +421,17 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do ...@@ -420,19 +421,17 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end end
it 'exposes correct variable properties' do it 'exposes correct variable properties' do
expect(@first_variable['key']).to eq "TRIGGER_KEY_1" first_variable = json_response['trigger']['variables'].first
expect(@first_variable['value']).to eq "TRIGGER_VALUE_1"
expect(@first_variable['public']).to eq false 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
end end
context 'with variables and user is not a mantainer' do context 'with variables and user is not a mantainer' do
before do before do
create(:ci_pipeline_variable, pipeline: pipeline, key: :TRIGGER_KEY_1, value: 'TRIGGER_VALUE_1')
get_show(id: job.id, format: :json) get_show(id: job.id, format: :json)
@first_variable = json_response['trigger']['variables'].first
end end
it 'returns a job_detail' do it 'returns a job_detail' do
...@@ -446,9 +445,12 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do ...@@ -446,9 +445,12 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end end
it 'exposes correct variable properties' do it 'exposes correct variable properties' do
expect(@first_variable['key']).to eq "TRIGGER_KEY_1" first_variable = json_response['trigger']['variables'].first
expect(@first_variable['value']).to be_nil
expect(@first_variable['public']).to eq false 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 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