Fix default sorting for subgroups and projects list

This commit is contained in:
Jacopo 2018-11-14 14:46:31 +01:00
parent 28e3a90be8
commit b45501395c
3 changed files with 13 additions and 1 deletions

View file

@ -178,7 +178,7 @@ class GroupDescendantsFinder
end end
def sort def sort
params.fetch(:sort, 'id_asc') params.fetch(:sort, 'created_desc')
end end
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord

View file

@ -0,0 +1,5 @@
---
title: Fix default sorting for subgroups and projects list
merge_request: 23058
author: Jacopo Beschi @jacopo-beschi
type: fixed

View file

@ -74,6 +74,13 @@ describe GroupDescendantsFinder do
end end
end end
it 'sorts elements by latest created as default' do
project1 = create(:project, namespace: group, created_at: 1.hour.ago)
project2 = create(:project, namespace: group)
expect(subject.execute).to eq([project2, project1])
end
context 'sorting by name' do context 'sorting by name' do
let!(:project1) { create(:project, namespace: group, name: 'a', path: 'project-a') } let!(:project1) { create(:project, namespace: group, name: 'a', path: 'project-a') }
let!(:project2) { create(:project, namespace: group, name: 'z', path: 'project-z') } let!(:project2) { create(:project, namespace: group, name: 'z', path: 'project-z') }