popular posts: fix exception when given blank date param.
Flexbooru calls this endpoint with a blank date param.
This commit is contained in:
@@ -38,7 +38,7 @@ module Explore
|
|||||||
private
|
private
|
||||||
|
|
||||||
def parse_date(params)
|
def parse_date(params)
|
||||||
date = params[:date] ? Date.parse(params[:date]) : Time.zone.today
|
date = params[:date].present? ? Date.parse(params[:date]) : Time.zone.today
|
||||||
scale = params[:scale].in?(["day", "week", "month"]) ? params[:scale] : "day"
|
scale = params[:scale].in?(["day", "week", "month"]) ? params[:scale] : "day"
|
||||||
min_date = date.send("beginning_of_#{scale}")
|
min_date = date.send("beginning_of_#{scale}")
|
||||||
max_date = date.send("next_#{scale}").send("beginning_of_#{scale}")
|
max_date = date.send("next_#{scale}").send("beginning_of_#{scale}")
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ module Explore
|
|||||||
get popular_explore_posts_path
|
get popular_explore_posts_path
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "work with a blank date" do
|
||||||
|
get popular_explore_posts_path(date: "")
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "#curated" do
|
context "#curated" do
|
||||||
|
|||||||
Reference in New Issue
Block a user