Fix use of User#expires_at in SpecHelpers#stub_auth_for
#82
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, if
User#expires_atwas defined, but it was set tonil, theexpires_incalculation was returning a large negative integer. This was becausenil.to_iis 0 and thususer.expires_at.to_i - Time.zone.now.to_iwas a value like-1744820986(for 2025-04-16 17:30) which meant the credentials were effectively immediately expired some time ago.This isn't a problem in e.g.
code-club-frontend, because the user factory setsUser#expires_atto a time a random number of seconds in the future, i.e. `rand(60..300).seconds.from_now.We've had to do something similar in
experience-cs, but I think a better solution is to default to using the 3600 fallback value ifUser#expires_atisniljust like we do ifUser#expires_atis not defined.