autocomplete: fix exception when type param is missing.
This commit is contained in:
@@ -20,7 +20,7 @@ class AutocompleteService
|
|||||||
|
|
||||||
def initialize(query, type, current_user: User.anonymous, limit: 10)
|
def initialize(query, type, current_user: User.anonymous, limit: 10)
|
||||||
@query = query.to_s
|
@query = query.to_s
|
||||||
@type = type.to_sym
|
@type = type.to_s.to_sym
|
||||||
@current_user = current_user
|
@current_user = current_user
|
||||||
@limit = limit
|
@limit = limit
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -35,6 +35,13 @@ class AutocompleteControllerTest < ActionDispatch::IntegrationTest
|
|||||||
assert_autocomplete_equals(["rating:safe"], "-rating:s", "tag_query")
|
assert_autocomplete_equals(["rating:safe"], "-rating:s", "tag_query")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "work for a missing type" do
|
||||||
|
get autocomplete_index_path(search: { query: "azur" }), as: :json
|
||||||
|
|
||||||
|
assert_response :success
|
||||||
|
assert_equal([], response.parsed_body)
|
||||||
|
end
|
||||||
|
|
||||||
should "not set session cookies when the response is publicly cached" do
|
should "not set session cookies when the response is publicly cached" do
|
||||||
get autocomplete_index_path(search: { query: "azur", type: "tag_query" }), as: :json
|
get autocomplete_index_path(search: { query: "azur", type: "tag_query" }), as: :json
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user