diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-04-24 08:06:49 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-04-24 08:06:49 +0000 |
commit | 92cb6d63543c75ec39570699ffbe958845472da9 (patch) | |
tree | 167eb079481ecec3d6d483145d23c8f27c4b96ba /spec/models/project_spec.rb | |
parent | 8a726a0842f4a8e5b86d2a44c7c16219632f4249 (diff) | |
parent | 82d66ac96d03a4caf6d4c3c86c51009e2a4fe9fb (diff) | |
download | gitlab-ce-92cb6d63543c75ec39570699ffbe958845472da9.tar.gz |
Merge branch '44447-expose-deploy-token-to-ci-cd' into 'master'
Expose Deploy Token info as environment variables to CI/CD jobs
Closes #44447
See merge request gitlab-org/gitlab-ce!18414
Diffstat (limited to 'spec/models/project_spec.rb')
-rw-r--r-- | spec/models/project_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 4002722e358..f00cebba364 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -3585,4 +3585,44 @@ describe Project do it { is_expected.not_to be_valid } end end + + describe '#gitlab_deploy_token' do + let(:project) { create(:project) } + + subject { project.gitlab_deploy_token } + + context 'when there is a gitlab deploy token associated' do + let!(:deploy_token) { create(:deploy_token, :gitlab_deploy_token, projects: [project]) } + + it { is_expected.to eq(deploy_token) } + end + + context 'when there is no a gitlab deploy token associated' do + it { is_expected.to be_nil } + end + + context 'when there is a gitlab deploy token associated but is has been revoked' do + let!(:deploy_token) { create(:deploy_token, :gitlab_deploy_token, :revoked, projects: [project]) } + it { is_expected.to be_nil } + end + + context 'when there is a gitlab deploy token associated but it is expired' do + let!(:deploy_token) { create(:deploy_token, :gitlab_deploy_token, :expired, projects: [project]) } + + it { is_expected.to be_nil } + end + + context 'when there is a deploy token associated with a different name' do + let!(:deploy_token) { create(:deploy_token, projects: [project]) } + + it { is_expected.to be_nil } + end + + context 'when there is a deploy token associated to a different project' do + let(:project_2) { create(:project) } + let!(:deploy_token) { create(:deploy_token, projects: [project_2]) } + + it { is_expected.to be_nil } + end + end end |