Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil TrzciƄski <ayufan@ayufan.eu>2018-04-10 10:31:30 +0300
committerRobert Speicher <rspeicher@gmail.com>2018-04-11 03:03:07 +0300
commit44b89668371dff6b32b7c077f6dddba6fd13d52f (patch)
tree5feb5899d1dd333f89d08ba8a0b9d9eb9edc6b72 /spec/models
parentbff933f0f1bfc83bbfbec40c7bd4181c88c175da (diff)
Merge branch 'deploy-tokens-container-registry-specs' into 'master'
Verify that deploy token has valid access when pulling container registry image Closes #45148 See merge request gitlab-org/gitlab-ce!18260
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/deploy_token_spec.rb31
1 files changed, 21 insertions, 10 deletions
diff --git a/spec/models/deploy_token_spec.rb b/spec/models/deploy_token_spec.rb
index 5a15c23def4..780b200e837 100644
--- a/spec/models/deploy_token_spec.rb
+++ b/spec/models/deploy_token_spec.rb
@@ -78,19 +78,30 @@ describe DeployToken do
describe '#has_access_to?' do
let(:project) { create(:project) }
- subject(:deploy_token) { create(:deploy_token, projects: [project]) }
+ subject { deploy_token.has_access_to?(project) }
- context 'when the deploy token has access to the project' do
- it 'should return true' do
- expect(deploy_token.has_access_to?(project)).to be_truthy
- end
+ context 'when deploy token is active and related to project' do
+ let(:deploy_token) { create(:deploy_token, projects: [project]) }
+
+ it { is_expected.to be_truthy }
end
- context 'when the deploy token does not have access to the project' do
- it 'should return false' do
- another_project = create(:project)
- expect(deploy_token.has_access_to?(another_project)).to be_falsy
- end
+ context 'when deploy token is active but not related to project' do
+ let(:deploy_token) { create(:deploy_token) }
+
+ it { is_expected.to be_falsy }
+ end
+
+ context 'when deploy token is revoked and related to project' do
+ let(:deploy_token) { create(:deploy_token, :revoked, projects: [project]) }
+
+ it { is_expected.to be_falsy }
+ end
+
+ context 'when deploy token is revoked and not related to the project' do
+ let(:deploy_token) { create(:deploy_token, :revoked) }
+
+ it { is_expected.to be_falsy }
end
end