Fix requiring of oauth2 #86
Merged
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.
The changes in #83 (which were released in v4.1.0) moved the
OauthClientclass (which uses theoauth2gem) from the Rails applications into therpi_authgem. At that point theoauth2gem was made a direct dependency ofrpi_authand the direct dependency onoauth2was removed from the Rails applications.I think this meant that the
oauth2gem was no longer being required automatically. And, although individual files in theoauth2gem were being required from individual files inrpi_auth, this meant that not all of the files inoauth2were being required. In particular, thelib/oauth2.rbfile which defines the top-levelOAuth2module and theOAuth2.configmethod was no longer being required. This led to exceptions like this one inexperience-cswhenRpiAuth::OauthClient#refresh_credentialswas called:This commit changes the require statements to just require
oauth2which in turn requires all the relevant files in theoauth2gem. The require statement inspec/rpi_auth/oauth_client_spec.rbis unnecessary, because it's automatically loadingRpiAuth::OauthClientwhich in turn loadsoauth2. This should mean we no longer see exceptions like the one above.I've tested that this fix works in
experience-csin https://github.com/RaspberryPiFoundation/experience-cs/pull/421 - I ran the Rails app and triggered a token refresh to check thatNoMethodErrorwas no longer being raised.