summaryrefslogtreecommitdiff
path: root/spec/models/ci/build_spec.rb
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-04-25 17:13:25 +0900
committerShinya Maeda <shinya@gitlab.com>2018-04-25 17:13:25 +0900
commitabde73c0492510a7c6f3d3d412e0971a9df8968d (patch)
tree3693fb0c974769b61c23b5245ea7da0e695bf364 /spec/models/ci/build_spec.rb
parent12711de2564e1aecbd68f926e28d0d3e2241da41 (diff)
parentab7b01aa30a20de547a133931318964dcd032f6b (diff)
downloadgitlab-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.rb32
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)