-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG FIX] Handles edge case where requested current_page > total_pages. #2399
Conversation
@bf4 should I be concerned with the failing tests, they seem unrelated to my changes? |
…ge is greater than total_pages adding tests fixing rubocop violation
@wasifhossain strange I squashed rebased and force pushed and github actions did not change, codedclimate did not re-run as far as I can tell. Should I close this PR and reopen? Appreciate you helping me on this 🙏. |
oh I am sorry in that case. let me do the reopening for you :) |
seems like it didn't help either. we might need to configure something in the ci file. will get back to you if we find something. thanks for the PR 👍 |
@f3z0 I have made a small addition in the CI file, so hopefully tests will run now if you rebase your branch again. thanks |
@wasifhossain awesome that worked 🙏 |
tests look fine! could you please add a line in the changelog documenting this. thanks |
@wasifhossain yes absolutely, I've added under v0.10.12 fixes. |
CHANGELOG.md
Outdated
@@ -15,6 +15,7 @@ Misc: | |||
Fixes: | |||
|
|||
- [#2398](https://github.com/rails-api/active_model_serializers/pull/2398) Update rails dependency to < 6.2 (@ritikesh) | |||
- [#2399](https://github.com/rails-api/active_model_serializers/pull/2399) Handles edge case where requested current_page > total_pages (@f3z0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as 0.10.12 has already been published, I guess this change would fit under Unreleased -> Fixes section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that, this makes more sense.
looks good to me! let's merge this 🙌 |
Purpose
Fixes an edge case whereby the client requests a current_page > total_pages.
Changes
ActiveModelSerializers::Adapter::JsonApi::PaginationLinks#next_page_url should return nil if there is no next_page however if the client incorrectly requests a pager greater than the total number of pages it will return an invalid next_page. Also similarly if the current_page is greater than total pages the prev_page_url should return the last previous page with results which would be equivalent to last_page_url.
Caveats
None.
Related GitHub issues
Did not see any.
Additional helpful information
N/A