diff --git a/app/logical/autocomplete_service.rb b/app/logical/autocomplete_service.rb index 23bb33f92..b870755b5 100644 --- a/app/logical/autocomplete_service.rb +++ b/app/logical/autocomplete_service.rb @@ -20,7 +20,7 @@ class AutocompleteService def initialize(query, type, current_user: User.anonymous, limit: 10) @query = query.to_s - @type = type.to_sym + @type = type.to_s.to_sym @current_user = current_user @limit = limit end diff --git a/test/functional/autocomplete_controller_test.rb b/test/functional/autocomplete_controller_test.rb index ae372ab1f..fa877579d 100644 --- a/test/functional/autocomplete_controller_test.rb +++ b/test/functional/autocomplete_controller_test.rb @@ -35,6 +35,13 @@ class AutocompleteControllerTest < ActionDispatch::IntegrationTest assert_autocomplete_equals(["rating:safe"], "-rating:s", "tag_query") 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 get autocomplete_index_path(search: { query: "azur", type: "tag_query" }), as: :json