-
Notifications
You must be signed in to change notification settings - Fork 408
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
Documentation: Check the consistency with page number assignation change in 9+ #739
Comments
incase others need this and this is closed as 'not fixing' i monkey patched it by
|
@phyzical thank you for your report. I am wondering how you don't get the automatic assignation of the Could you please use one of the Playground apps to show how to make it fail? |
I assume then it is just simply the fact its a redundant spec causing the issue to begin with, as its explicitly passing in the param. Based on what your saying its probably safe to just close this. Just figured id raise it as it does seem to be a functionality change not mentioned in the breaking changes.
|
and why it happens
|
That explains it. Indeed, if you explicitly pass a variable, you are responsible for passing it right.
I will check whether the docs and breaking changes are consistent with the current behavior before closing it. |
I'm testing on Pagy 8 I was unable to reproduce the results such that the first page is retrieved? I'm testing from the command line via the I also added a custom test in pagy 8 and was unable to replicate such that the first page of results would be received, Sane for pagy 9. _ { Pagy.new(count: 100, page: "blah") }.must_be_instance_of Pagy # fails
_ { Pagy.new(count: 0, page: "-1") }.must_raise Pagy::VariableError # passes
_ { Pagy.new(count: 0, page: "blah") }.must_raise Pagy::VariableError # passes
_ { Pagy.new(count: 0, page: -1) }.must_raise Pagy::VariableError # passes Also tested via console. /home/koshy/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pagy-8.6.3/lib/pagy.rb:94:in `block in setup_vars': expected :page >= 1; got -1 (Pagy::VariableError)
from /home/koshy/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pagy-8.6.3/lib/pagy.rb:93:in `each'
from /home/koshy/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pagy-8.6.3/lib/pagy.rb:93:in `setup_vars'
from /home/koshy/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pagy-8.6.3/lib/pagy.rb:30:in `initialize'
from /home/koshy/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pagy-8.6.3/lib/pagy/extras/array.rb:11:in `new'
from /home/koshy/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pagy-8.6.3/lib/pagy/extras/array.rb:11:in `pagy_array'
from (irb):8:in `<main>'
from /home/koshy/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/irb-1.12.0/exe/irb:9:in `<top (required)>'
from /home/koshy/.rbenv/versions/3.1.2/bin/irb:25:in `load'
from /home/koshy/.rbenv/versions/3.1.2/bin/irb:25:in `<main>'
irb(main):009> pagy_array((1..1000).to_a, page: "blah")
/home/koshy/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pagy-8.6.3/lib/pagy.rb:94:in `block in setup_vars': expected :page >= 1; got "blah" (Pagy::VariableError)
from /home/koshy/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pagy-8.6.3/lib/pagy.rb:93:in `each'
from /home/koshy/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pagy-8.6.3/lib/pagy.rb:93:in `setup_vars'
from /home/koshy/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pagy-8.6.3/lib/pagy.rb:30:in `initialize'
from /home/koshy/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pagy-8.6.3/lib/pagy/extras/array.rb:11:in `new'
from /home/koshy/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pagy-8.6.3/lib/pagy/extras/array.rb:11:in `pagy_array'
from (irb):9:in `<main>'
from /home/koshy/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/irb-1.12.0/exe/irb:9:in `<top (required)>'
from /home/koshy/.rbenv/versions/3.1.2/bin/irb:25:in `load'
from /home/koshy/.rbenv/versions/3.1.2/bin/irb:25:in `<main>' It would seem that the behaviour is expected? Any ideas on how to replicate the behaviour of pagy 8 such that the results are acheived? |
thanks for giving it a go, ill try by best to summarise the usecase that resulted in me raising this (closed source so its obviously a bit paraphrased) So its in the context of a request with rails, so maybe rails request handling of the params has a say in all this maybe? that's all i can really think of code wise i cant seem to find anything super fancy This is the spec chunk hitting an endpoint and manually providing the values
This is that endpoint
Pagination module (funny i know as there was logic that should have complained if these tests provided these values but i guess dead code?.. that became live in 9? idk...)
Ill do one more dive to see if im looking down the wrong rabbit hole and there's a view or something that is hitting the code path causing the issue nah it is 100% |
I have been unable to reproduce this issue with a complete and self-contained example. If I have made an error or if one is produced, please feel free to re-open this issue. |
👀 Before submitting...
🧐 REQUIREMENTS
💬 Description
Not sure if this is a bug but in 9 we had a set of tests fail that assumed that invalid page numbers result in the first page to be returned i.e providing
page: -1
page: 'blah'
in 8 would result in the first page of results
in 9 we get
TBH, i think its just a set of silly tests ourside but i could see it biting larger projects where people do dodge to reset pages ect.
Might just be worth getting added to the breaking changes list?
The text was updated successfully, but these errors were encountered: