mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 12:14:36 +08:00
DEV: Add per_page as public param for TopicQuery (#30716)
This change allows controllers that construct TopicQuery parameters, to pass per_page into the TopicQuery constructor as an option. I can't see why this shouldn't be a public param, so long as we properly validate the value! Internal discussion at t/145686.
This commit is contained in:

committed by
GitHub

parent
473e37e7b3
commit
a89086f799
@ -726,6 +726,21 @@ RSpec.describe ListController do
|
||||
get "/top?period=decadely"
|
||||
expect(response.status).to eq(400)
|
||||
end
|
||||
|
||||
describe "per page" do
|
||||
it "uses value from params when present" do
|
||||
get "/top.json?per_page=5"
|
||||
|
||||
expect(response.parsed_body["topic_list"]["per_page"]).to eq(5)
|
||||
end
|
||||
|
||||
it "uses SiteSetting.topics_per_period_in_top_page when per_page param isn't present" do
|
||||
SiteSetting.topics_per_period_in_top_page = 32
|
||||
get "/top.json"
|
||||
|
||||
expect(response.parsed_body["topic_list"]["per_page"]).to eq(32)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "category" do
|
||||
|
Reference in New Issue
Block a user