mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-09-18 22:34:56 +09:00
Hello world
First open source release of Campfire 🎉
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
require "test_helper"
|
||||
|
||||
class Autocompletable::UsersControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
sign_in :david
|
||||
end
|
||||
|
||||
test "search returns matching users" do
|
||||
get autocompletable_users_url(format: :json), params: { query: "da" }
|
||||
|
||||
assert_response :success
|
||||
assert_equal "David", response.parsed_body.first["name"]
|
||||
end
|
||||
|
||||
test "search results escape HTML in names" do
|
||||
users(:david).update!(name: "David <script>alert(123)</script>")
|
||||
|
||||
get autocompletable_users_url(format: :json), params: { query: "da" }
|
||||
|
||||
assert_response :success
|
||||
assert_equal "David <script>alert(123)</script>", response.parsed_body.first["name"]
|
||||
end
|
||||
|
||||
test "room search returns matching users" do
|
||||
get autocompletable_users_url(room_id: rooms(:hq).id, format: :json), params: { query: "da" }
|
||||
|
||||
assert_response :success
|
||||
assert_equal "David", response.parsed_body.first["name"]
|
||||
end
|
||||
|
||||
test "room search is scoped by membership" do
|
||||
sign_in :kevin
|
||||
|
||||
assert_not_includes users(:kevin).rooms, rooms(:watercooler)
|
||||
|
||||
assert_raises ActiveRecord::RecordNotFound do
|
||||
get autocompletable_users_url(room_id: rooms(:watercooler).id, format: :json), params: { query: "da" }
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user