Ensure user toggles on board edit page are cached properly

Not including the disabled flag as part of the cache resulted in
issues like the one described in #1992
This commit is contained in:
Mike Dalessio
2025-12-08 14:21:56 -05:00
parent c2380dc057
commit abe48f0efa
4 changed files with 40 additions and 2 deletions
@@ -166,4 +166,28 @@ class BoardsControllerTest < ActionDispatch::IntegrationTest
assert_select "button:not([disabled])", text: "Select all"
assert_select "button:not([disabled])", text: "Select none"
end
test "access toggle disabled state is cached correctly" do
board = boards(:writebook)
david = users(:david)
with_actionview_partial_caching do
# privileged user
assert users(:kevin).can_administer_board?(board)
get edit_board_path(board)
assert_response :success
assert_select "input.switch__input[name='user_ids[]'][value='#{david.id}']:not([disabled])"
# unprivileged user
logout_and_sign_in_as :jz
assert_not users(:jz).can_administer_board?(board)
get edit_board_path(board)
assert_response :success
assert_select "input.switch__input[name='user_ids[]'][value='#{david.id}'][disabled]"
end
end
end