Commit c60cb393 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'bvl-deploy-token' into 'master'

Fix deploy tokens without `expire_at` crashes

Closes #49904

See merge request gitlab-org/gitlab-ce!20992
parents 367e7520 a6268d30
......@@ -30,7 +30,7 @@ class DeployToken < ActiveRecord::Base
end
def active?
!revoked && expires_at > Date.today
!revoked && !expired?
end
def scopes
......@@ -63,6 +63,12 @@ class DeployToken < ActiveRecord::Base
private
def expired?
return false unless expires_at
expires_at < Date.today
end
def ensure_at_least_one_scope
errors.add(:base, "Scopes can't be blank") unless read_repository || read_registry
end
......
......@@ -74,6 +74,14 @@ describe DeployToken do
expect(deploy_token.active?).to be_falsy
end
end
context "when it hasn't been revoked and has no expiry" do
let(:deploy_token) { create(:deploy_token, expires_at: nil) }
it 'should return true' do
expect(deploy_token.active?).to be_truthy
end
end
end
describe '#username' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment