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:
authorMayra Cabrera <mcabrera@gitlab.com>2018-03-30 01:56:35 +0300
committerMayra Cabrera <mcabrera@gitlab.com>2018-04-07 05:20:16 +0300
commit370fc05da7f95bf6621867a71d51493cf3899e25 (patch)
tree040f676c8c6ccf04d5ebfdbbe064a844affd63f5 /spec/models/deploy_token_spec.rb
parentdb18993f652425b72c4b854e18a002e0ec44b196 (diff)
Implement 'read_repo' for DeployTokens
This will allow to download a repo using the token from the DeployToken
Diffstat (limited to 'spec/models/deploy_token_spec.rb')
-rw-r--r--spec/models/deploy_token_spec.rb46
1 files changed, 32 insertions, 14 deletions
diff --git a/spec/models/deploy_token_spec.rb b/spec/models/deploy_token_spec.rb
index bd27da63dfe..26d846ac6c8 100644
--- a/spec/models/deploy_token_spec.rb
+++ b/spec/models/deploy_token_spec.rb
@@ -1,38 +1,56 @@
require 'spec_helper'
describe DeployToken do
+ let(:deploy_token) { create(:deploy_token) }
+
it { is_expected.to belong_to :project }
describe 'validations' do
- let(:project_deploy_token) { build(:deploy_token) }
-
context 'with no scopes defined' do
it 'should not be valid' do
- project_deploy_token.scopes = []
+ deploy_token.scopes = []
- expect(project_deploy_token).not_to be_valid
- expect(project_deploy_token.errors[:scopes].first).to eq("can't be blank")
+ expect(deploy_token).not_to be_valid
+ expect(deploy_token.errors[:scopes].first).to eq("can't be blank")
end
end
end
describe '#ensure_token' do
- let(:project_deploy_token) { build(:deploy_token) }
-
it 'should ensure a token' do
- project_deploy_token.token = nil
- project_deploy_token.save
+ deploy_token.token = nil
+ deploy_token.save
- expect(project_deploy_token.token).not_to be_empty
+ expect(deploy_token.token).not_to be_empty
end
end
describe '#revoke!' do
- subject { create(:deploy_token) }
-
it 'should update revoke attribute' do
- subject.revoke!
- expect(subject.revoked?).to be_truthy
+ deploy_token.revoke!
+ expect(deploy_token.revoked?).to be_truthy
+ end
+ end
+
+ describe "#active?" do
+ context "when it has been revoked" do
+ it 'should return false' do
+ deploy_token.revoke!
+ expect(deploy_token.active?).to be_falsy
+ end
+ end
+
+ context "when it hasn't been revoked" do
+ it 'should return true' do
+ expect(deploy_token.active?).to be_truthy
+ end
+ end
+ end
+
+ describe '#username' do
+ it 'returns Ghost username' do
+ ghost = User.ghost
+ expect(deploy_token.username).to eq(ghost.username)
end
end
end