summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJacob Schatz <jschatz@gitlab.com>2016-04-20 19:18:32 +0000
committerJacob Schatz <jschatz@gitlab.com>2016-04-20 19:18:32 +0000
commit692c35e6f499598d0c6f91eb83ca8837ca93e07f (patch)
treec8af3c1ea77c3845957e34f238950a379339cd01 /spec
parent9a60887199ef1087285ea6997f2eb117f87d0a03 (diff)
parent490f77318b8d54be30558c3ef8914335ed83549b (diff)
downloadgitlab-ce-692c35e6f499598d0c6f91eb83ca8837ca93e07f.tar.gz
Merge branch 'multi-filter-labels' into 'master'
Mutliple label filter Fixes #989 See merge request !3438
Diffstat (limited to 'spec')
-rw-r--r--spec/features/issues/filter_by_labels_spec.rb172
-rw-r--r--spec/features/issues/filter_issues_spec.rb9
-rw-r--r--spec/features/merge_requests/filter_by_milestone_spec.rb6
-rw-r--r--spec/finders/issues_finder_spec.rb16
4 files changed, 202 insertions, 1 deletions
diff --git a/spec/features/issues/filter_by_labels_spec.rb b/spec/features/issues/filter_by_labels_spec.rb
new file mode 100644
index 00000000000..7944403f874
--- /dev/null
+++ b/spec/features/issues/filter_by_labels_spec.rb
@@ -0,0 +1,172 @@
+require 'rails_helper'
+
+feature 'Issue filtering by Labels', feature: true do
+ let(:project) { create(:project, :public) }
+ let!(:user) { create(:user)}
+ let!(:label) { create(:label, project: project) }
+
+ before do
+ ['bug', 'feature', 'enhancement'].each do |title|
+ create(:label,
+ project: project,
+ title: title)
+ end
+
+ issue1 = create(:issue, title: "Bugfix1", project: project)
+ issue1.labels << project.labels.find_by(title: 'bug')
+
+ issue2 = create(:issue, title: "Bugfix2", project: project)
+ issue2.labels << project.labels.find_by(title: 'bug')
+ issue2.labels << project.labels.find_by(title: 'enhancement')
+
+ issue3 = create(:issue, title: "Feature1", project: project)
+ issue3.labels << project.labels.find_by(title: 'feature')
+
+ project.team << [user, :master]
+ login_as(user)
+
+ visit namespace_project_issues_path(project.namespace, project)
+ end
+
+ context 'filter by label bug', js: true do
+ before do
+ page.find('.js-label-select').click
+ sleep 0.5
+ execute_script("$('.dropdown-menu-labels li:contains(\"bug\") a').click()")
+ page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
+ sleep 2
+ end
+
+ it 'should show issue "Bugfix1" and "Bugfix2" in issues list' do
+ expect(page).to have_content "Bugfix1"
+ expect(page).to have_content "Bugfix2"
+ end
+
+ it 'should not show "Feature1" in issues list' do
+ expect(page).not_to have_content "Feature1"
+ end
+
+ it 'should show label "bug" in filtered-labels' do
+ expect(find('.filtered-labels')).to have_content "bug"
+ end
+
+ it 'should not show label "feature" and "enhancement" in filtered-labels' do
+ expect(find('.filtered-labels')).not_to have_content "feature"
+ expect(find('.filtered-labels')).not_to have_content "enhancement"
+ end
+ end
+
+ context 'filter by label feature', js: true do
+ before do
+ page.find('.js-label-select').click
+ sleep 0.5
+ execute_script("$('.dropdown-menu-labels li:contains(\"feature\") a').click()")
+ page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
+ sleep 2
+ end
+
+ it 'should show issue "Feature1" in issues list' do
+ expect(page).to have_content "Feature1"
+ end
+
+ it 'should not show "Bugfix1" and "Bugfix2" in issues list' do
+ expect(page).not_to have_content "Bugfix2"
+ expect(page).not_to have_content "Bugfix1"
+ end
+
+ it 'should show label "feature" in filtered-labels' do
+ expect(find('.filtered-labels')).to have_content "feature"
+ end
+
+ it 'should not show label "bug" and "enhancement" in filtered-labels' do
+ expect(find('.filtered-labels')).not_to have_content "bug"
+ expect(find('.filtered-labels')).not_to have_content "enhancement"
+ end
+ end
+
+ context 'filter by label enhancement', js: true do
+ before do
+ page.find('.js-label-select').click
+ sleep 0.5
+ execute_script("$('.dropdown-menu-labels li:contains(\"enhancement\") a').click()")
+ page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
+ sleep 2
+ end
+
+ it 'should show issue "Bugfix2" in issues list' do
+ expect(page).to have_content "Bugfix2"
+ end
+
+ it 'should not show "Feature1" and "Bugfix1" in issues list' do
+ expect(page).not_to have_content "Feature1"
+ expect(page).not_to have_content "Bugfix1"
+ end
+
+ it 'should show label "enhancement" in filtered-labels' do
+ expect(find('.filtered-labels')).to have_content "enhancement"
+ end
+
+ it 'should not show label "feature" and "bug" in filtered-labels' do
+ expect(find('.filtered-labels')).not_to have_content "bug"
+ expect(find('.filtered-labels')).not_to have_content "feature"
+ end
+ end
+
+ context 'filter by label enhancement or feature', js: true do
+ before do
+ page.find('.js-label-select').click
+ sleep 0.5
+ execute_script("$('.dropdown-menu-labels li:contains(\"enhancement\") a').click()")
+ execute_script("$('.dropdown-menu-labels li:contains(\"feature\") a').click()")
+ page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
+ sleep 2
+ end
+
+ it 'should show issue "Bugfix2" or "Feature1" in issues list' do
+ expect(page).to have_content "Bugfix2"
+ expect(page).to have_content "Feature1"
+ end
+
+ it 'should not show "Bugfix1" in issues list' do
+ expect(page).not_to have_content "Bugfix1"
+ end
+
+ it 'should show label "enhancement" and "feature" in filtered-labels' do
+ expect(find('.filtered-labels')).to have_content "enhancement"
+ expect(find('.filtered-labels')).to have_content "feature"
+ end
+
+ it 'should not show label "bug" in filtered-labels' do
+ expect(find('.filtered-labels')).not_to have_content "bug"
+ end
+ end
+
+ context 'filter by label enhancement or bug in issues list', js: true do
+ before do
+ page.find('.js-label-select').click
+ sleep 0.5
+ execute_script("$('.dropdown-menu-labels li:contains(\"enhancement\") a').click()")
+ execute_script("$('.dropdown-menu-labels li:contains(\"bug\") a').click()")
+ page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
+ sleep 2
+ end
+
+ it 'should show issue "Bugfix2" or "Bugfix1" in issues list' do
+ expect(page).to have_content "Bugfix2"
+ expect(page).to have_content "Bugfix1"
+ end
+
+ it 'should not show "Feature1"' do
+ expect(page).not_to have_content "Feature1"
+ end
+
+ it 'should show label "bug" and "enhancement" in filtered-labels' do
+ expect(find('.filtered-labels')).to have_content "bug"
+ expect(find('.filtered-labels')).to have_content "enhancement"
+ end
+
+ it 'should not show label "feature" in filtered-labels' do
+ expect(find('.filtered-labels')).not_to have_content "feature"
+ end
+ end
+end
diff --git a/spec/features/issues/filter_issues_spec.rb b/spec/features/issues/filter_issues_spec.rb
index 69b22232f10..192e3619375 100644
--- a/spec/features/issues/filter_issues_spec.rb
+++ b/spec/features/issues/filter_issues_spec.rb
@@ -84,14 +84,20 @@ describe 'Filter issues', feature: true do
it 'should filter by any label' do
find('.dropdown-menu-labels a', text: 'Any Label').click
+ page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
+ sleep 2
+
page.within '.labels-filter' do
expect(page).to have_content 'Any Label'
end
- expect(find('.js-label-select .dropdown-toggle-text')).to have_content('Label')
+ expect(find('.js-label-select .dropdown-toggle-text')).to have_content('Any Label')
end
it 'should filter by no label' do
find('.dropdown-menu-labels a', text: 'No Label').click
+ page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
+ sleep 2
+
page.within '.labels-filter' do
expect(page).to have_content 'No Label'
end
@@ -121,6 +127,7 @@ describe 'Filter issues', feature: true do
find('.js-label-select').click
find('.dropdown-menu-labels .dropdown-content a', text: label.title).click
+ page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
sleep 2
end
diff --git a/spec/features/merge_requests/filter_by_milestone_spec.rb b/spec/features/merge_requests/filter_by_milestone_spec.rb
index c57ab5f3b03..e3ecd60a5f3 100644
--- a/spec/features/merge_requests/filter_by_milestone_spec.rb
+++ b/spec/features/merge_requests/filter_by_milestone_spec.rb
@@ -2,8 +2,14 @@ require 'rails_helper'
feature 'Merge Request filtering by Milestone', feature: true do
let(:project) { create(:project, :public) }
+ let!(:user) { create(:user)}
let(:milestone) { create(:milestone, project: project) }
+ before do
+ project.team << [user, :master]
+ login_as(user)
+ end
+
scenario 'filters by no Milestone', js: true do
create(:merge_request, :with_diffs, source_project: project)
create(:merge_request, :simple, source_project: project, milestone: milestone)
diff --git a/spec/finders/issues_finder_spec.rb b/spec/finders/issues_finder_spec.rb
index b1648055462..bc607a29751 100644
--- a/spec/finders/issues_finder_spec.rb
+++ b/spec/finders/issues_finder_spec.rb
@@ -62,6 +62,22 @@ describe IssuesFinder do
expect(issues).to eq([issue2])
end
+ it 'returns unique issues when filtering by multiple labels' do
+ label2 = create(:label, project: project2)
+
+ create(:label_link, label: label2, target: issue2)
+
+ params = {
+ scope: 'all',
+ label_name: [label.title, label2.title].join(','),
+ state: 'opened'
+ }
+
+ issues = IssuesFinder.new(user, params).execute
+
+ expect(issues).to eq([issue2])
+ end
+
it 'should filter by no label name' do
params = { scope: "all", label_name: Label::None.title, state: 'opened' }
issues = IssuesFinder.new(user, params).execute