summaryrefslogtreecommitdiff
path: root/spec/models/deploy_token_spec.rb
diff options
context:
space:
mode:
authorMayra Cabrera <mcabrera@gitlab.com>2018-04-05 22:02:13 -0500
committerMayra Cabrera <mcabrera@gitlab.com>2018-04-06 21:20:17 -0500
commitc4f56a88029c1fe73bf6efb062b5f77a65282fed (patch)
tree890a869e8ce06a5438b38c8e9dca9529362cc2f4 /spec/models/deploy_token_spec.rb
parenta475411f4380ef4d0260940206e2553da3b2f3ee (diff)
downloadgitlab-ce-c4f56a88029c1fe73bf6efb062b5f77a65282fed.tar.gz
Increase test suite around deploy tokens behavior
Also, fixes broken specs
Diffstat (limited to 'spec/models/deploy_token_spec.rb')
-rw-r--r--spec/models/deploy_token_spec.rb21
1 files changed, 20 insertions, 1 deletions
diff --git a/spec/models/deploy_token_spec.rb b/spec/models/deploy_token_spec.rb
index 395c97f13a5..1adc049ca58 100644
--- a/spec/models/deploy_token_spec.rb
+++ b/spec/models/deploy_token_spec.rb
@@ -70,8 +70,27 @@ describe DeployToken do
end
describe '#username' do
- it 'returns Ghost username' do
+ it 'returns a harcoded username' do
expect(deploy_token.username).to eq("gitlab+deploy-token-#{deploy_token.id}")
end
end
+
+ describe '#has_access_to?' do
+ let(:project) { create(:project) }
+
+ subject(:deploy_token) { create(:deploy_token, projects: [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
+ 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
+ end
+ end
end