summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
authorjhampton <jhampton@gitlab.com>2018-12-06 17:45:55 -0500
committerjhampton <jhampton@gitlab.com>2018-12-06 17:45:55 -0500
commit1bf28d48082d485d04acc4aadff18789229a896a (patch)
tree04d1d8759c1606d1eade4e132cd27e1570472d7c /spec/controllers
parent242bead1fb9ee2921a5795c6ec3de6f24a860752 (diff)
downloadgitlab-ce-1bf28d48082d485d04acc4aadff18789229a896a.tar.gz
Adjusts tests per MR feedback
- Updates tests / applies patterns per MR feedback
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/projects/jobs_controller_spec.rb41
1 files changed, 31 insertions, 10 deletions
diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb
index 8fd8af9360c..fd3a8fb6340 100644
--- a/spec/controllers/projects/jobs_controller_spec.rb
+++ b/spec/controllers/projects/jobs_controller_spec.rb
@@ -398,40 +398,61 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
end
- context 'with variables' do
+ context 'with variables and user is a maintainer' 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)
end
- it 'exposes trigger information and variables' do
+ before(:each) do
+ @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
+
+ 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
- expect(json_response['trigger']['variables'].first['key']).to eq "TRIGGER_KEY_1"
- expect(json_response['trigger']['variables'].first['value']).to eq "TRIGGER_VALUE_1"
- expect(json_response['trigger']['variables'].first['public']).to eq false
+ 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
- context 'with no variable values' do
+ 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')
get_show(id: job.id, format: :json)
end
- it 'exposes trigger information and variables' do
+ before(:each) do
+ @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
+
+ 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
- expect(json_response['trigger']['variables'].first['key']).to eq "TRIGGER_KEY_1"
- expect(json_response['trigger']['variables'].first['value']).to be_nil
- expect(json_response['trigger']['variables'].first['public']).to eq false
+ 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
end
end
end