diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-04-25 17:13:25 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-04-25 17:13:25 +0900 |
commit | abde73c0492510a7c6f3d3d412e0971a9df8968d (patch) | |
tree | 3693fb0c974769b61c23b5245ea7da0e695bf364 /spec/models/ci/build_spec.rb | |
parent | 12711de2564e1aecbd68f926e28d0d3e2241da41 (diff) | |
parent | ab7b01aa30a20de547a133931318964dcd032f6b (diff) | |
download | gitlab-ce-abde73c0492510a7c6f3d3d412e0971a9df8968d.tar.gz |
Merge branch 'master' into live-trace-v2-efficient-destroy-all
Diffstat (limited to 'spec/models/ci/build_spec.rb')
-rw-r--r-- | spec/models/ci/build_spec.rb | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index fcdc31c8984..3158e006720 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -2035,6 +2035,34 @@ describe Ci::Build do expect(build).not_to be_persisted end end + + context 'for deploy tokens' do + let(:deploy_token) { create(:deploy_token, :gitlab_deploy_token) } + + let(:deploy_token_variables) do + [ + { key: 'CI_DEPLOY_USER', value: deploy_token.name, public: true }, + { key: 'CI_DEPLOY_PASSWORD', value: deploy_token.token, public: false } + ] + end + + context 'when gitlab-deploy-token exists' do + before do + project.deploy_tokens << deploy_token + end + + it 'should include deploy token variables' do + is_expected.to include(*deploy_token_variables) + end + end + + context 'when gitlab-deploy-token does not exist' do + it 'should not include deploy token variables' do + expect(subject.find { |v| v[:key] == 'CI_DEPLOY_USER'}).to be_nil + expect(subject.find { |v| v[:key] == 'CI_DEPLOY_PASSWORD'}).to be_nil + end + end + end end describe '#scoped_variables' do @@ -2083,7 +2111,9 @@ describe Ci::Build do CI_REGISTRY_USER CI_REGISTRY_PASSWORD CI_REPOSITORY_URL - CI_ENVIRONMENT_URL] + CI_ENVIRONMENT_URL + CI_DEPLOY_USER + CI_DEPLOY_PASSWORD] build.scoped_variables.map { |env| env[:key] }.tap do |names| expect(names).not_to include(*keys) |