summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
authorjhampton <jhampton@gitlab.com>2018-12-06 08:08:02 -0500
committerjhampton <jhampton@gitlab.com>2018-12-06 08:08:02 -0500
commit51a61e53b2b6bc4d6224332a01848f80699d4b28 (patch)
tree678368bb4ad4f05cd8c54b93c2e9e359529c3d5f /spec/controllers
parentb6600129bfaa4c8667e06016f546ac71d03f1bf4 (diff)
downloadgitlab-ce-51a61e53b2b6bc4d6224332a01848f80699d4b28.tar.gz
Fixes broken tests
- Adjusts behavior to cover conditional trigger variable values
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/projects/jobs_controller_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb
index da3d658d061..8fd8af9360c 100644
--- a/spec/controllers/projects/jobs_controller_spec.rb
+++ b/spec/controllers/projects/jobs_controller_spec.rb
@@ -400,6 +400,7 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state 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)
@@ -415,6 +416,24 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
expect(json_response['trigger']['variables'].first['public']).to eq false
end
end
+
+ context 'with no variable values' 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
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(response).to match_response_schema('job/job_details')
+ 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
+ end
end
def get_show(**extra_params)