Commit a6268d30 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Fix deploy tokens without `expire_at` crashes

parent 367e7520
......@@ -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