15 minute fix: Add default argument to JsonApiSortParam#13369
Merged
citizen428 merged 2 commits intomasterfrom Apr 14, 2021
Merged
15 minute fix: Add default argument to JsonApiSortParam#13369citizen428 merged 2 commits intomasterfrom
citizen428 merged 2 commits intomasterfrom
Conversation
rhymes
approved these changes
Apr 13, 2021
Contributor
rhymes
left a comment
There was a problem hiding this comment.
Make sense! Give it to Rails that instantiates a new controller each request :D
djuber
approved these changes
Apr 13, 2021
| RSpec.describe JsonApiSortParam do | ||
| let!(:controller) { Class.new { include JsonApiSortParam }.new } | ||
| let!(:controller) do | ||
| Class.new(Api::V0::ApiController) { include JsonApiSortParam }.new |
Contributor
There was a problem hiding this comment.
this change was required (instead of Class.new) since you're now relying on Controller behavior, like having a params method. Makes sense.
The existing tests (with an explicit param string) were left unchanged - also makes sense.
Contributor
Author
There was a problem hiding this comment.
Yes, I wanted to test both the default and explicit param cases and the explicit params are also easier to test so I didn't want to go and change existing tests to an IMO less readable form.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What type of PR is this? (check all applicable)
Description
I recently added the
JsonApiSortParamconcern. However, the includedparse_sort_parammethod always required the param string to be passed it explicitly. Given that is a controller concern we can assume that aparamsmethod will always be available in the including scope, so I'm using this as the default now.Related Tickets & Documents
n/a
QA Instructions, Screenshots, Recordings
Refactoring only, specs should still pass
UI accessibility concerns?
n/a
Added tests?
[Forem core team only] How will this change be communicated?