circleci
0 of 1 new or added line in 1 file covered. (0.0%)
2381 existing lines in 150 files now uncovered.3599 of 6198 relevant lines covered (58.07%)
5.05 hits per line
1 |
# frozen_string_literal: true
|
|
2 |
|
|
3 |
# This class is responsible for persisting
|
|
4 |
# OAuth tokens to the database
|
|
5 |
class OAuthToken < ApplicationRecord |
1✔ |
6 |
def token |
1✔ |
UNCOV
7
|
if expiration_time && not_yet_expired
|
× |
UNCOV
8
|
self[:token] |
× |
9 |
else
|
|
UNCOV
10
|
fetch_new_token |
× |
UNCOV
11
|
reload[:token]
|
× |
12 |
end
|
|
13 |
end
|
|
14 |
|
|
15 |
private |
1✔ |
16 |
|
|
17 |
def fetch_new_token |
1✔ |
UNCOV
18
|
service = OAuthService.new(service: self.service, endpoint:) |
× |
UNCOV
19
|
self.token = service.new_token
|
× |
UNCOV
20
|
self.expiration_time = service.expiration_time
|
× |
UNCOV
21
|
save |
× |
22 |
end
|
|
23 |
|
|
24 |
def not_yet_expired |
1✔ |
UNCOV
25
|
(Time.zone.now < expiration_time)
|
× |
26 |
end
|
|
27 |
end
|