List one page of account members at a time

Since administrators were grouped apart from members (b52c318), the account
settings page loads every user to split them and renders all of them. The
lazy next page still starts at the 501st user, so on an account with more
than 500 people, scrolling down lists those users a second time.

Load administrators on their own and page only members, both on the settings
page and on the pages that follow it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0142qgjggdJ2KDdGk7RF9Xm9
This commit is contained in:
Marcello Costagliola
2026-10-05 14:56:22 +02:00
parent 345e63718f
commit f864403c2c
4 changed files with 23 additions and 6 deletions
@@ -42,6 +42,18 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
end
end
test "edit lists a page of members and the next page carries on from it" do
User.insert_all 501.times.map { |i| { name: "Member #{i}", email_address: "member#{i}@37signals.com" } }
get edit_account_url
first_page = listed_user_ids
get account_users_url(page: 2, format: :turbo_stream)
next_page = listed_user_ids
assert_not_empty next_page
assert_equal User.active.without_bots.ids.sort, (first_page + next_page).sort
end
test "update" do
assert users(:david).administrator?
@@ -58,4 +70,9 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
put account_url, params: { account: { name: "Different" } }
assert_response :forbidden
end
private
def listed_user_ids
response.body.scan(/id="role_user_(\d+)"/).flatten.map(&:to_i)
end
end