diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-02-22 00:01:48 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-02-22 00:01:48 +0300 |
commit | d90053d50ea848462558d036225968cdf6c02dde (patch) | |
tree | 45be9914d7fefebe40b0ee1ea834fe2521f0854d /spec | |
parent | 7ff0c8ae57e6a88c86afae4f8e08bfacfb34d761 (diff) | |
parent | 0a11d5e24559d9e22a3e9ab7311646f762a13562 (diff) |
Merge branch 'dz-sort-labels-alphabetically' into 'master'
Sort labels alphabetically on issues and merge requests list
Closes #57003
See merge request gitlab-org/gitlab-ce!25470
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/issuables/issuable_list_spec.rb | 24 | ||||
-rw-r--r-- | spec/helpers/labels_helper_spec.rb | 13 |
2 files changed, 37 insertions, 0 deletions
diff --git a/spec/features/issuables/issuable_list_spec.rb b/spec/features/issuables/issuable_list_spec.rb index 2f45ef856a5..7b6e9cd66b2 100644 --- a/spec/features/issuables/issuable_list_spec.rb +++ b/spec/features/issuables/issuable_list_spec.rb @@ -28,6 +28,22 @@ describe 'issuable list' do expect(first('.fa-thumbs-down').find(:xpath, '..')).to have_content(1) expect(first('.fa-comments').find(:xpath, '..')).to have_content(2) end + + it 'sorts labels alphabetically' do + label1 = create(:label, project: project, title: 'a') + label2 = create(:label, project: project, title: 'z') + label3 = create(:label, project: project, title: 'X') + label4 = create(:label, project: project, title: 'B') + issuable = create_issuable(issuable_type) + issuable.labels << [label1, label2, label3, label4] + + visit_issuable_list(issuable_type) + + expect(all('.label-link')[0].text).to have_content('B') + expect(all('.label-link')[1].text).to have_content('X') + expect(all('.label-link')[2].text).to have_content('a') + expect(all('.label-link')[3].text).to have_content('z') + end end it "counts merge requests closing issues icons for each issue" do @@ -45,6 +61,14 @@ describe 'issuable list' do end end + def create_issuable(issuable_type) + if issuable_type == :issue + create(:issue, project: project) + else + create(:merge_request, source_project: project) + end + end + def create_issuables(issuable_type) 3.times do |n| issuable = diff --git a/spec/helpers/labels_helper_spec.rb b/spec/helpers/labels_helper_spec.rb index c04f679bcf0..012678db9c2 100644 --- a/spec/helpers/labels_helper_spec.rb +++ b/spec/helpers/labels_helper_spec.rb @@ -236,4 +236,17 @@ describe LabelsHelper do expect(labels_filter_path(format: :json)).to eq(dashboard_labels_path(format: :json)) end end + + describe 'labels_sorted_by_title' do + it 'sorts labels alphabetically' do + label1 = double(:label, title: 'a') + label2 = double(:label, title: 'B') + label3 = double(:label, title: 'c') + label4 = double(:label, title: 'D') + labels = [label1, label2, label3, label4] + + expect(labels_sorted_by_title(labels)) + .to match_array([label2, label4, label1, label3]) + end + end end |