diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2019-02-21 19:06:14 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2019-02-21 23:19:24 +0300 |
commit | 0a11d5e24559d9e22a3e9ab7311646f762a13562 (patch) | |
tree | d737114f2140d04b9e44f71cbbf138a212b0eb35 /spec | |
parent | c8bf9f78f3e481cb7e74384fa45b46b864fa523a (diff) |
Sort labels alphabetically
Sorts labels alphabetically on issues (and merge requests) list.
Before it was order id desc.
Now it will be consistent with sidebar and labels page.
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
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 |