mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-10-07 07:10:10 +09:00
Ask for JSON when autocompleting people to ping
`as: "json"` is a @rails/request.js option; plain fetch ignores it and sends `Accept: */*`, so Autocompletable::UsersController answered with its HTML format and response.json() threw. The new ping form never showed any suggestions. Send an explicit Accept header instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -120,7 +120,7 @@ export default class BaseAutocompleteHandler {
|
||||
|
||||
#fetchAutocompletables(url) {
|
||||
if (url) {
|
||||
return fetch(url, { as: "json" }).then(response => response.json())
|
||||
return fetch(url, { headers: { Accept: "application/json" } }).then(response => response.json())
|
||||
} else {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
require "application_system_test_case"
|
||||
|
||||
class StartingPingsTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in "kevin@37signals.com"
|
||||
end
|
||||
|
||||
test "suggesting people to ping" do
|
||||
visit new_rooms_direct_url
|
||||
|
||||
find("[data-autocomplete-target='input']").send_keys("Jas")
|
||||
|
||||
assert_selector "suggestion-option[role='option']", text: "Jason"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user