mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Validation of min_posts and max_posts didn't work
This commit is contained in:
@@ -13,14 +13,14 @@ class TopicQuery
|
|||||||
def self.validators
|
def self.validators
|
||||||
@validators ||= begin
|
@validators ||= begin
|
||||||
|
|
||||||
zero_or_more = lambda do |x|
|
|
||||||
Integer === x && x >= 0
|
|
||||||
end
|
|
||||||
|
|
||||||
int = lambda do |x|
|
int = lambda do |x|
|
||||||
Integer === x || (String === x && x.match?(/^-?[0-9]+$/))
|
Integer === x || (String === x && x.match?(/^-?[0-9]+$/))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
zero_or_more = lambda do |x|
|
||||||
|
int.call(x) && x.to_i >= 0
|
||||||
|
end
|
||||||
|
|
||||||
array_int_or_int = lambda do |x|
|
array_int_or_int = lambda do |x|
|
||||||
int.call(x) || (
|
int.call(x) || (
|
||||||
Array === x && x.length > 0 && x.all?(&int)
|
Array === x && x.length > 0 && x.all?(&int)
|
||||||
|
|||||||
@@ -36,6 +36,12 @@ RSpec.describe ListController do
|
|||||||
|
|
||||||
get "/latest.json?exclude_category_ids=-1"
|
get "/latest.json?exclude_category_ids=-1"
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
|
get "/latest.json?max_posts=12"
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
|
get "/latest.json?min_posts=0"
|
||||||
|
expect(response.status).to eq(200)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't throw an error with page params as an array" do
|
it "doesn't throw an error with page params as an array" do
|
||||||
|
|||||||
Reference in New Issue
Block a user