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:
Diffstat (limited to 'spec/models/deploy_token_spec.rb')
-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