Handle out-of-range and bogus pagination inputs. #137

Merged
merged 3 commits into from Nov 26, 2012

Conversation

Projects
None yet
3 participants
@sodabrew
Owner

sodabrew commented Nov 7, 2012

Handles bogus pagination inputs.

If you visit your local puppet dashboard at /nodes?per_page=whaaa you get an exception.
If you visit /nodes?page=1000000000000 you will get "no matching nodes".

With this change, an invalid per_page uses the default per_page. A too-large page number will show the last page, and a too-small or invalid page number will show the first page.

@jeffweiss

This comment has been minimized.

Show comment Hide comment
@jeffweiss

jeffweiss Nov 8, 2012

Contributor

@sodabrew can you add tests for these cases to spec/helpers/paginate_scope_helper_spec.rb?

Contributor

jeffweiss commented Nov 8, 2012

@sodabrew can you add tests for these cases to spec/helpers/paginate_scope_helper_spec.rb?

@sodabrew

This comment has been minimized.

Show comment Hide comment
@sodabrew

sodabrew Nov 8, 2012

Owner

Thanks! Unit tests forgotten, added :)

Owner

sodabrew commented Nov 8, 2012

Thanks! Unit tests forgotten, added :)

@haus

This comment has been minimized.

Show comment Hide comment
@haus

haus Nov 21, 2012

Contributor

@sodabrew The last new test depends on new will_paginate behavior that isn't in the 2.3.15 that is vendored in dashboard currently. When per_page is nil, as it will be in that example, the current will_paginate defaults to 30, while the newer will_paginate defaults to WillPaginate.per_page. All the tests pass except that one.

https://github.com/mislav/will_paginate/blob/260c1c45ed8c31917614710015a9dcab7981943a/lib/will_paginate/array.rb

Contributor

haus commented Nov 21, 2012

@sodabrew The last new test depends on new will_paginate behavior that isn't in the 2.3.15 that is vendored in dashboard currently. When per_page is nil, as it will be in that example, the current will_paginate defaults to 30, while the newer will_paginate defaults to WillPaginate.per_page. All the tests pass except that one.

https://github.com/mislav/will_paginate/blob/260c1c45ed8c31917614710015a9dcab7981943a/lib/will_paginate/array.rb

@sodabrew

This comment has been minimized.

Show comment Hide comment
@sodabrew

sodabrew Nov 26, 2012

Owner

Thanks! I'll fix that per_page usage.

Owner

sodabrew commented Nov 26, 2012

Thanks! I'll fix that per_page usage.

haus added a commit that referenced this pull request Nov 26, 2012

Merge pull request #137 from sodabrew/patch-1
Handle out-of-range and bogus pagination inputs.

@haus haus merged commit 0eef69e into sodabrew:master Nov 26, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment