mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Don't give error 500 when invalid date param is given to admin reports (#8658)
Providing invalid dates as the end_date or start_date param causes a 500 error and creates noise in the logs. This will handle the error and returns a proper 400 response to the client with a message that explains what the problem is.
This commit is contained in:
@@ -47,6 +47,24 @@ describe Admin::ReportsController do
|
||||
expect(JSON.parse(response.body)["reports"][1]["type"]).to eq("not_found")
|
||||
end
|
||||
end
|
||||
|
||||
context "invalid start or end dates" do
|
||||
it "doesn't return 500 error" do
|
||||
get "/admin/reports/bulk.json", params: {
|
||||
reports: {
|
||||
topics: { limit: 10, start_date: "2015-0-1" }
|
||||
}
|
||||
}
|
||||
expect(response.status).to eq(400)
|
||||
|
||||
get "/admin/reports/bulk.json", params: {
|
||||
reports: {
|
||||
topics: { limit: 10, end_date: "2015-0-1" }
|
||||
}
|
||||
}
|
||||
expect(response.status).to eq(400)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user