add validation to exclude_category_ids
This commit is contained in:
parent
12bab65167
commit
bc47148d35
|
@ -17,13 +17,14 @@ class TopicQuery
|
||||||
Integer === x && x >= 0
|
Integer === x && x >= 0
|
||||||
end
|
end
|
||||||
|
|
||||||
array_zero_or_more = lambda do |x|
|
array_int = lambda do |x|
|
||||||
Array === x && x.length > 0 && x.all? { |i| Integer === i && i >= 0 }
|
Array === x && x.length > 0 && x.all? { |i| Integer === i }
|
||||||
end
|
end
|
||||||
|
|
||||||
{
|
{
|
||||||
max_posts: zero_or_more,
|
max_posts: zero_or_more,
|
||||||
min_posts: zero_or_more,
|
min_posts: zero_or_more,
|
||||||
|
exclude_category_ids: array_int
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,6 +22,12 @@ RSpec.describe ListController do
|
||||||
|
|
||||||
get "/latest?max_posts=bob"
|
get "/latest?max_posts=bob"
|
||||||
expect(response.status).to eq(400)
|
expect(response.status).to eq(400)
|
||||||
|
|
||||||
|
get "/latest?exclude_category_ids=bob"
|
||||||
|
expect(response.status).to eq(400)
|
||||||
|
|
||||||
|
get "/latest?exclude_category_ids[]=bob"
|
||||||
|
expect(response.status).to eq(400)
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue