diff options
author | Mark Fletcher <mark@gitlab.com> | 2017-12-20 12:17:39 +0000 |
---|---|---|
committer | Mark Fletcher <mark@gitlab.com> | 2017-12-20 19:34:50 +0000 |
commit | e7deeddc1b88a2809bd03dbcb876c5d460c297e5 (patch) | |
tree | c2887944c554f916dc26c3fa106a0098e9f1f8b8 | |
parent | 225980db35cc468b892aa71d26aa622e5fe08b96 (diff) | |
download | gitlab-ce-e7deeddc1b88a2809bd03dbcb876c5d460c297e5.tar.gz |
Enable sorting by name in the Groups dropdown
-rw-r--r-- | app/helpers/sorting_helper.rb | 2 | ||||
-rw-r--r-- | changelogs/unreleased/36958-enable-ordering-projects-subgroups-by-name.yml | 5 | ||||
-rw-r--r-- | spec/finders/group_descendants_finder_spec.rb | 35 |
3 files changed, 42 insertions, 0 deletions
diff --git a/app/helpers/sorting_helper.rb b/app/helpers/sorting_helper.rb index 52805334680..36a311dfa8a 100644 --- a/app/helpers/sorting_helper.rb +++ b/app/helpers/sorting_helper.rb @@ -44,6 +44,8 @@ module SortingHelper def groups_sort_options_hash { + sort_value_name => sort_title_name, + sort_value_name_desc => sort_title_name_desc, sort_value_recently_created => sort_title_recently_created, sort_value_oldest_created => sort_title_oldest_created, sort_value_recently_updated => sort_title_recently_updated, diff --git a/changelogs/unreleased/36958-enable-ordering-projects-subgroups-by-name.yml b/changelogs/unreleased/36958-enable-ordering-projects-subgroups-by-name.yml new file mode 100644 index 00000000000..8348e3e8ceb --- /dev/null +++ b/changelogs/unreleased/36958-enable-ordering-projects-subgroups-by-name.yml @@ -0,0 +1,5 @@ +--- +title: Enable ordering of groups and their children by name +merge_request: +author: +type: added diff --git a/spec/finders/group_descendants_finder_spec.rb b/spec/finders/group_descendants_finder_spec.rb index 074914420a1..ae050f36b4a 100644 --- a/spec/finders/group_descendants_finder_spec.rb +++ b/spec/finders/group_descendants_finder_spec.rb @@ -73,6 +73,41 @@ describe GroupDescendantsFinder do expect(finder.execute).to contain_exactly(matching_project) end end + + context 'sorting by name' do + let!(:project1) { create(:project, namespace: group, name: 'a', path: 'project-a') } + let!(:project2) { create(:project, namespace: group, name: 'z', path: 'project-z') } + let(:params) do + { + sort: 'name_asc' + } + end + + it 'sorts elements by name' do + expect(subject.execute).to eq( + [ + project1, + project2 + ] + ) + end + + context 'with nested groups', :nested_groups do + let!(:subgroup1) { create(:group, parent: group, name: 'a', path: 'sub-a') } + let!(:subgroup2) { create(:group, parent: group, name: 'z', path: 'sub-z') } + + it 'sorts elements by name' do + expect(subject.execute).to eq( + [ + subgroup1, + subgroup2, + project1, + project2 + ] + ) + end + end + end end context 'with nested groups', :nested_groups do |