Commit 6a3caadded3cb3c8b3fd1ee2cd4772ed73274dac
Committed by
Gabriela Navarro
1 parent
e5d9ef3a
Exists in
master
and in
29 other branches
sort_members: sort community members alphabetically in manage members and view all page
(ActionItem2909) Signed-off-by: Alex Campelo <campelo.al1@gmail.com> Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com> SIgned-off-by: Gabriela Navarro <navarro1703@gmail.com>
Showing
5 changed files
with
31 additions
and
3 deletions
Show diff stats
app/controllers/my_profile/profile_members_controller.rb
app/controllers/public/profile_controller.rb
... | ... | @@ -67,7 +67,7 @@ class ProfileController < PublicController |
67 | 67 | |
68 | 68 | def members |
69 | 69 | if is_cache_expired?(profile.members_cache_key(params)) |
70 | - @members = profile.members.includes(relations_to_include).paginate(:per_page => members_per_page, :page => params[:npage]) | |
70 | + @members = profile.members_by_name.includes(relations_to_include).paginate(:per_page => members_per_page, :page => params[:npage]) | |
71 | 71 | end |
72 | 72 | end |
73 | 73 | ... | ... |
app/models/profile.rb
app/views/profile_members/_members_list.rhtml
1 | -<% collection = @collection == :profile_admins ? profile.admins : profile.members %> | |
1 | +<% collection = @collection == :profile_admins ? profile.admins : profile.members_by_name %> | |
2 | 2 | <% title = @title ? @title : _('Current members') %> |
3 | 3 | <% remove_action = @remove_action ? @remove_action : {:action => 'unassociate'} %> |
4 | 4 | ... | ... |
test/unit/profile_test.rb
... | ... | @@ -1692,6 +1692,30 @@ class ProfileTest < ActiveSupport::TestCase |
1692 | 1692 | assert_equal 1, community.members_count |
1693 | 1693 | end |
1694 | 1694 | |
1695 | + should 'order members by name alphabetically considering special characters' do | |
1696 | + community = fast_create(Community) | |
1697 | + | |
1698 | + community.add_member(create_user('José').person) | |
1699 | + community.add_member(create_user('João').person) | |
1700 | + community.add_member(create_user('Mariana').person) | |
1701 | + members = community.members_by_name | |
1702 | + | |
1703 | + assert_equal "João", members.first.name | |
1704 | + assert_equal "Mariana", members.last.name | |
1705 | + end | |
1706 | + | |
1707 | + should 'order members by name alphabetically considering upper and lower cases' do | |
1708 | + community = fast_create(Community) | |
1709 | + | |
1710 | + community.add_member(create_user('mariana').person) | |
1711 | + community.add_member(create_user('João').person) | |
1712 | + community.add_member(create_user('guest').person) | |
1713 | + members = community.members_by_name | |
1714 | + | |
1715 | + assert_equal "guest", members.first.name | |
1716 | + assert_equal "mariana", members.last.name | |
1717 | + end | |
1718 | + | |
1695 | 1719 | should 'know if url is the profile homepage' do |
1696 | 1720 | profile = fast_create(Profile) |
1697 | 1721 | ... | ... |