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.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/models/deploy_token_spec.rb b/spec/models/deploy_token_spec.rb
index 60a3e3fc0e2..c7e1d5fc0d5 100644
--- a/spec/models/deploy_token_spec.rb
+++ b/spec/models/deploy_token_spec.rb
@@ -124,6 +124,39 @@ RSpec.describe DeployToken do
end
end
+ # override the default PolicyActor implementation that always returns false
+ describe "#deactivated?" do
+ context "when it has been revoked" do
+ it 'returns true' do
+ deploy_token.revoke!
+
+ expect(deploy_token.deactivated?).to be_truthy
+ end
+ end
+
+ context "when it hasn't been revoked and is not expired" do
+ it 'returns false' do
+ expect(deploy_token.deactivated?).to be_falsy
+ end
+ end
+
+ context "when it hasn't been revoked and is expired" do
+ it 'returns false' do
+ deploy_token.update_attribute(:expires_at, Date.today - 5.days)
+
+ expect(deploy_token.deactivated?).to be_truthy
+ end
+ end
+
+ context "when it hasn't been revoked and has no expiry" do
+ let(:deploy_token) { create(:deploy_token, expires_at: nil) }
+
+ it 'returns false' do
+ expect(deploy_token.deactivated?).to be_falsy
+ end
+ end
+ end
+
describe '#username' do
context 'persisted records' do
it 'returns a default username if none is set' do