circleci
0 of 4 new or added lines in 3 files covered. (0.0%)
2099 existing lines in 140 files now uncovered.3881 of 6191 relevant lines covered (62.69%)
74.9 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
|