fix: Loading teams for team option of author filter/validator #713
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.
Fix loading teams for team option of author filter/validator.
Context
My previous PR #710 added an author validator. However, the API classes (mocked in the tests) access the context, and the context in
lib/validators/options_processor/options/team.js
is not the one I expected (it's a special validator context, different from the context inlib/filters/options_processor/options/team.js
(correct one).API calls are mocked for unit tests, but they log information taken from the context, and this doesn't work with the validator context.
Changes
I introduced a new function in
lib/validators/options_processor/teams.js
and moved most of the logic there (shared for filter/validator), and removed theoptions_processor/options/team.js
classes because we don't always have the correct context there.This method is called prior to processing the other options (and potentially results in an early return if unsuccessful), and then the
team
key is simply removed from the options.This follows the pattern for similar cases, for example, see lib/validators/changeset.js#L58