Sort group/project members alphabetically by default

parent 4b7a3d0c
class Groups::GroupMembersController < Groups::ApplicationController
include MembershipActions
include SortingHelper
# Authorize
before_action :authorize_admin_group_member!, except: [:index, :leave, :request_access]
def index
@sort = params[:sort].presence || sort_value_name
@project = @group.projects.find(params[:project_id]) if params[:project_id]
@members = @group.group_members
@members = @members.non_invite unless can?(current_user, :admin_group, @group)
@members = @members.search(params[:search]) if params[:search].present?
@members = @members.sort(@sort = params[:sort]) if params[:sort].present?
@members = @members.sort(@sort)
@members = @members.page(params[:page]).per(50)
@requesters = AccessRequestsFinder.new(@group).execute(current_user)
......
- @sort ||= sort_value_last_joined
.dropdown.inline
= dropdown_toggle(member_sort_options_hash[@sort], { toggle: 'dropdown' }, { id: 'sort-members-dropdown' })
%ul.dropdown-menu.dropdown-menu-align-right.dropdown-menu-selectable
......
......@@ -12,6 +12,13 @@ feature 'Groups > Members > Sorting', feature: true do
login_as(owner)
end
scenario 'sorts alphabetically by default' do
visit_members_list(sort: nil)
expect(first_member).to include(owner.name)
expect(second_member).to include(developer.name)
end
scenario 'sorts by access level ascending' do
visit_members_list(sort: :access_level_asc)
......
......@@ -12,6 +12,13 @@ feature 'Projects > Members > Sorting', feature: true do
login_as(master)
end
scenario 'sorts alphabetically by default' do
visit_members_list(sort: nil)
expect(first_member).to include(master.name)
expect(second_member).to include(developer.name)
end
scenario 'sorts by access level ascending' do
visit_members_list(sort: :access_level_asc)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment