Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / scan_container (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
CI / system-test (push) Has been cancelled
Build and publish image / build (push) Has been cancelled
The access check form POSTed and re-rendered :new with a 200 HTML
response, which Turbo rejects ("Form responses must redirect to
another location"), so the result panel never appeared. Since the
check is a read-only query, switch to a GET form and fold the lookup
into the new action. Results are now bookmarkable via the URL.
Bump version to 0.16.2.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
48 lines
1.6 KiB
Ruby
48 lines
1.6 KiB
Ruby
require "test_helper"
|
|
|
|
module Admin
|
|
class AccessChecksControllerTest < ActionDispatch::IntegrationTest
|
|
setup do
|
|
@admin = users(:two)
|
|
sign_in_as(@admin)
|
|
@kavita = applications(:kavita_app)
|
|
end
|
|
|
|
test "new renders the form with users and applications" do
|
|
get admin_access_path
|
|
assert_response :success
|
|
assert_match @kavita.name, response.body
|
|
assert_match "alice@example.com", response.body
|
|
end
|
|
|
|
test "returns 'can access' with via group when user is in an allowed group" do
|
|
get admin_access_path, params: {
|
|
user_id: users(:alice).id,
|
|
application_id: @kavita.id
|
|
}
|
|
assert_response :success
|
|
assert_match "can access", response.body
|
|
assert_match "Administrators", response.body # alice is in admin_group; kavita has admin_group
|
|
end
|
|
|
|
test "returns 'cannot access' with reason when user shares no group with the app" do
|
|
lonely = User.create!(email_address: "lonely@example.com", password: "password123", skip_auto_assign: true)
|
|
get admin_access_path, params: {
|
|
user_id: lonely.id,
|
|
application_id: @kavita.id
|
|
}
|
|
assert_response :success
|
|
assert_match "cannot access", response.body
|
|
assert_match "shares no group", response.body
|
|
end
|
|
|
|
test "renders form unchanged when ids are missing" do
|
|
get admin_access_path, params: {user_id: "", application_id: ""}
|
|
assert_response :success
|
|
# No result panel should render. The panel-only phrases:
|
|
refute_match "Granted via", response.body
|
|
refute_match "Reason:", response.body
|
|
end
|
|
end
|
|
end
|