mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-10-08 07:40:08 +09:00
Group administrators separately from members with visual divider
This commit is contained in:
@@ -3,7 +3,9 @@ class AccountsController < ApplicationController
|
|||||||
before_action :set_account
|
before_action :set_account
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
set_page_and_extract_portion_from account_users.ordered, per_page: 500
|
users = account_users.ordered.without_bots
|
||||||
|
@administrators, @members = users.partition(&:administrator?)
|
||||||
|
set_page_and_extract_portion_from users, per_page: 500
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|||||||
@@ -100,7 +100,13 @@
|
|||||||
|
|
||||||
<menu class="flex flex-column gap margin-none pad">
|
<menu class="flex flex-column gap margin-none pad">
|
||||||
<turbo-frame id="account_users">
|
<turbo-frame id="account_users">
|
||||||
<%= render partial: "accounts/users/user", collection: @page.records, as: :user %>
|
<%= render partial: "accounts/users/user", collection: @administrators, as: :user %>
|
||||||
|
|
||||||
|
<% if @administrators.any? && @members.any? %>
|
||||||
|
<hr class="separator full-width" style="--border-style: solid">
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= render partial: "accounts/users/user", collection: @members, as: :user %>
|
||||||
<%= render "accounts/users/next_page_container", page: @page.next_param unless @page.last? %>
|
<%= render "accounts/users/next_page_container", page: @page.next_param unless @page.last? %>
|
||||||
</turbo-frame>
|
</turbo-frame>
|
||||||
</menu>
|
</menu>
|
||||||
|
|||||||
@@ -10,6 +10,38 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
assert_response :ok
|
assert_response :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "edit groups administrators separately from members with a divider" do
|
||||||
|
get edit_account_url
|
||||||
|
|
||||||
|
assert_response :ok
|
||||||
|
|
||||||
|
# Verify the divider exists between administrator and member sections
|
||||||
|
assert_select "turbo-frame#account_users hr.separator.full-width"
|
||||||
|
|
||||||
|
# Verify administrators appear before the divider and members appear after
|
||||||
|
# by checking the order of user names in the response body
|
||||||
|
administrators = users(:david, :jason).map(&:name)
|
||||||
|
members = users(:jz, :kevin).map(&:name)
|
||||||
|
|
||||||
|
response_body = response.body
|
||||||
|
|
||||||
|
# Find positions of divider and user names
|
||||||
|
divider_position = response_body.index('hr class="separator full-width"')
|
||||||
|
assert divider_position, "Divider should exist in the response"
|
||||||
|
|
||||||
|
administrators.each do |name|
|
||||||
|
name_position = response_body.index("<strong>#{name}</strong>")
|
||||||
|
assert name_position, "Administrator #{name} should appear in the response"
|
||||||
|
assert name_position < divider_position, "Administrator #{name} should appear before the divider"
|
||||||
|
end
|
||||||
|
|
||||||
|
members.each do |name|
|
||||||
|
name_position = response_body.index("<strong>#{name}</strong>")
|
||||||
|
assert name_position, "Member #{name} should appear in the response"
|
||||||
|
assert name_position > divider_position, "Member #{name} should appear after the divider"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
test "update" do
|
test "update" do
|
||||||
assert users(:david).administrator?
|
assert users(:david).administrator?
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user