FIX: Sort group owners and members together (#15708)

Sorting group members worked always kept the group owners at the top of
the list. This commit keeps the group owners at the top of the list only
when no order exists.
This commit is contained in:
Bianca Nenciu
2022-02-09 11:43:58 +02:00
committed by GitHub
parent f704deca17
commit c38114f0c6
2 changed files with 24 additions and 13 deletions

View File

@ -547,6 +547,23 @@ describe GroupsController do
expect(members.last['added_at']).to eq(first_user.created_at.as_json)
end
it "can sort items" do
sign_in(user)
group.update!(visibility_level: Group.visibility_levels[:logged_on_users])
other_user = Fabricate(:user)
group.add_owner(other_user)
get "/groups/#{group.name}/members.json"
expect(response.parsed_body["members"].map { |u| u["id"] }).to eq([other_user.id, user.id])
expect(response.parsed_body["owners"].map { |u| u["id"] }).to eq([other_user.id])
get "/groups/#{group.name}/members.json?order=added_at&asc=1"
expect(response.parsed_body["members"].map { |u| u["id"] }).to eq([user.id, other_user.id])
expect(response.parsed_body["owners"].map { |u| u["id"] }).to eq([other_user.id])
end
end
describe '#posts_feed' do