summaryrefslogtreecommitdiff
path: root/spec/features/projects/labels/issues_sorted_by_priority_spec.rb
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-06-15 15:43:12 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-06-15 15:43:12 +0800
commite75391889e8bb13f9ead60eac88ffac5d9081f78 (patch)
tree10fd092d4011a923cfb8dd79d469061d3fb0aa4a /spec/features/projects/labels/issues_sorted_by_priority_spec.rb
parent8c0b619d40e4d113ef592f4ae7a4b6afa320f225 (diff)
parentbf4455d14659f1fde6391164b38310d361bf407d (diff)
downloadgitlab-ce-e75391889e8bb13f9ead60eac88ffac5d9081f78.tar.gz
Merge branch 'master' into new-issue-by-email
* master: (1246 commits) Update CHANGELOG Update tests to make it work with Turbolinks approach Use Turbolink instead of ajax Reinitialize checkboxes to toggle event bindings Turn off handlers before binding events Removed console.log Uses outerWidth instead of width Revert "Added API endpoint for Sidekiq Metrics" Added API endpoint for Sidekiq Metrics Added CHANGELOG entry for allocations Gem/name fix Filter out classes without names in the sampler Update the allocations Gem to 1.0.5 Put all sidebar icons in fixed width container Instrument private/protected methods Fix Ci::Build#artifacts_expire_in= when assigning invalid duration Fix grammar and syntax Update CI API docs UI and copywriting improvements Factorize members mails into a new Emails::Members module Factorize access request routes into a new :access_requestable route concern Factorize #request_access and #approve_access_request into a new AccessRequestActions controller concern ...
Diffstat (limited to 'spec/features/projects/labels/issues_sorted_by_priority_spec.rb')
-rw-r--r--spec/features/projects/labels/issues_sorted_by_priority_spec.rb87
1 files changed, 87 insertions, 0 deletions
diff --git a/spec/features/projects/labels/issues_sorted_by_priority_spec.rb b/spec/features/projects/labels/issues_sorted_by_priority_spec.rb
new file mode 100644
index 00000000000..461f1737928
--- /dev/null
+++ b/spec/features/projects/labels/issues_sorted_by_priority_spec.rb
@@ -0,0 +1,87 @@
+require 'spec_helper'
+
+feature 'Issue prioritization', feature: true do
+
+ let(:user) { create(:user) }
+ let(:project) { create(:project, name: 'test', namespace: user.namespace) }
+
+ # Labels
+ let(:label_1) { create(:label, title: 'label_1', project: project, priority: 1) }
+ let(:label_2) { create(:label, title: 'label_2', project: project, priority: 2) }
+ let(:label_3) { create(:label, title: 'label_3', project: project, priority: 3) }
+ let(:label_4) { create(:label, title: 'label_4', project: project, priority: 4) }
+ let(:label_5) { create(:label, title: 'label_5', project: project) } # no priority
+
+ # According to https://gitlab.com/gitlab-org/gitlab-ce/issues/14189#note_4360653
+ context 'when issues have one label' do
+ scenario 'Are sorted properly' do
+
+ # Issues
+ issue_1 = create(:issue, title: 'issue_1', project: project)
+ issue_2 = create(:issue, title: 'issue_2', project: project)
+ issue_3 = create(:issue, title: 'issue_3', project: project)
+ issue_4 = create(:issue, title: 'issue_4', project: project)
+ issue_5 = create(:issue, title: 'issue_5', project: project)
+
+ # Assign labels to issues disorderly
+ issue_4.labels << label_1
+ issue_3.labels << label_2
+ issue_5.labels << label_3
+ issue_2.labels << label_4
+ issue_1.labels << label_5
+
+ login_as user
+ visit namespace_project_issues_path(project.namespace, project, sort: 'priority')
+
+ # Ensure we are indicating that issues are sorted by priority
+ expect(page).to have_selector('.dropdown-toggle', text: 'Priority')
+
+ page.within('.issues-holder') do
+ issue_titles = all('.issues-list .issue-title-text').map(&:text)
+
+ expect(issue_titles).to eq(['issue_4', 'issue_3', 'issue_5', 'issue_2', 'issue_1'])
+ end
+ end
+ end
+
+ context 'when issues have multiple labels' do
+ scenario 'Are sorted properly' do
+
+ # Issues
+ issue_1 = create(:issue, title: 'issue_1', project: project)
+ issue_2 = create(:issue, title: 'issue_2', project: project)
+ issue_3 = create(:issue, title: 'issue_3', project: project)
+ issue_4 = create(:issue, title: 'issue_4', project: project)
+ issue_5 = create(:issue, title: 'issue_5', project: project)
+ issue_6 = create(:issue, title: 'issue_6', project: project)
+ issue_7 = create(:issue, title: 'issue_7', project: project)
+ issue_8 = create(:issue, title: 'issue_8', project: project)
+
+ # Assign labels to issues disorderly
+ issue_5.labels << label_1 # 1
+ issue_5.labels << label_2
+ issue_8.labels << label_1 # 2
+ issue_1.labels << label_2 # 3
+ issue_1.labels << label_3
+ issue_3.labels << label_2 # 4
+ issue_3.labels << label_4
+ issue_7.labels << label_2 # 5
+ issue_2.labels << label_3 # 6
+ issue_4.labels << label_4 # 7
+ issue_6.labels << label_5 # 8 - No priority
+
+ login_as user
+ visit namespace_project_issues_path(project.namespace, project, sort: 'priority')
+
+ expect(page).to have_selector('.dropdown-toggle', text: 'Priority')
+
+ page.within('.issues-holder') do
+ issue_titles = all('.issues-list .issue-title-text').map(&:text)
+
+ expect(issue_titles[0..1]).to contain_exactly('issue_5', 'issue_8')
+ expect(issue_titles[2..4]).to contain_exactly('issue_1', 'issue_3', 'issue_7')
+ expect(issue_titles[5..-1]).to eq(['issue_2', 'issue_4', 'issue_6'])
+ end
+ end
+ end
+end