File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ def update_last_used(client_id)
35
35
36
36
module ApiKeyExtensions
37
37
def update_last_used! ( now = nil )
38
- return if last_used_at && ( last_used_at == Time . zone . now . beginning_of_day )
38
+ # return if last_used_at && (last_used_at == Time.zone.now.beginning_of_day)
39
39
40
40
super ( Time . zone . now . beginning_of_day )
41
41
end
Original file line number Diff line number Diff line change 19
19
it 'does not update last_used_at if already set to beginning of the day' do
20
20
user_api_key . update! ( last_used_at : Time . zone . now . beginning_of_day )
21
21
22
- expect ( user_api_key ) . not_to receive ( :update_column )
23
- expect ( user_api_key ) . not_to receive ( :update_columns )
22
+ allow ( user_api_key ) . to receive ( :update_column )
23
+ allow ( user_api_key ) . to receive ( :update_columns )
24
24
25
25
expect {
26
26
user_api_key . update_last_used ( "client_id_1" )
27
27
} . not_to change { user_api_key . reload . last_used_at }
28
+
29
+
30
+ expect ( user_api_key ) . not_to receive ( :update_column )
31
+ expect ( user_api_key ) . not_to receive ( :update_columns )
28
32
end
29
33
30
34
it 'updates client_id and destroys other keys with same client_id and user_id' do
48
52
end
49
53
50
54
it 'does not perform any database write if last_used_at is already set to the beginning of the day' do
51
- api_key . update! ( last_used_at : Time . zone . now . beginning_of_day )
55
+ api_key . update! ( last_used_at : Time . zone . now . beginning_of_day )
52
56
53
- expect ( api_key ) . not_to receive ( :update_column )
54
- expect ( api_key ) . not_to receive ( :update_columns )
57
+ allow ( api_key ) . to receive ( :update_column )
58
+ allow ( api_key ) . to receive ( :update_columns )
55
59
56
- api_key . update_last_used!
60
+ api_key . update_last_used!
61
+
62
+ expect ( api_key ) . not_to have_received ( :update_column )
63
+ expect ( api_key ) . not_to have_received ( :update_columns )
57
64
end
58
65
end
59
66
end
You can’t perform that action at this time.
0 commit comments