DEV: Fix failing spec.

This commit is contained in:
Guo Xiang Tan 2019-04-23 18:25:21 +08:00
parent 97dcd50e51
commit d07605d885
3 changed files with 6 additions and 4 deletions

View File

@ -27,7 +27,7 @@ class UserBadge < ActiveRecord::Base
private
def single_grant_badge?
self.badge.single_grant?
self.badge ? self.badge.single_grant? : true
end
end

View File

@ -7,7 +7,7 @@ RSpec.describe Jobs::AutoExpireUserApiKeys do
context 'when user api key is unused in last 1 days' do
before do
SiteSetting.expire_user_api_keys_days = true
SiteSetting.expire_user_api_keys_days = 1
end
it 'should revoke the key' do
@ -17,7 +17,7 @@ RSpec.describe Jobs::AutoExpireUserApiKeys do
described_class.new.execute({})
expect(key1.reload.revoked_at).to eq(Time.zone.now)
expect(key1.reload.revoked_at).to be_within(1.second).of(Time.zone.now)
expect(key2.reload.revoked_at).to eq(nil)
end
end

View File

@ -4,7 +4,9 @@ require_dependency 'user_badge'
describe UserBadge do
context 'validations' do
before(:each) { BadgeGranter.grant(Fabricate(:badge), Fabricate(:user)) }
let(:badge) { Fabricate(:badge) }
let(:user) { Fabricate(:user) }
let(:subject) { BadgeGranter.grant(badge, user) }
it { is_expected.to validate_presence_of(:badge_id) }
it { is_expected.to validate_presence_of(:user_id) }