summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-04-20 10:56:28 +0200
committerJames Lopez <james@jameslopez.es>2016-04-20 10:56:28 +0200
commitaf18cddddf4ecb402ac613ddcc1f313f6adb7aad (patch)
tree02395653f7c79013b3c894e776c158f2bfeba672 /spec
parent8619208b644f2acdc30ccf36209ac56527bb4188 (diff)
downloadgitlab-ce-af18cddddf4ecb402ac613ddcc1f313f6adb7aad.tar.gz
udpated a few things based on MR feedback. Also added model spec
Diffstat (limited to 'spec')
-rw-r--r--spec/features/issues/filter_by_labels_spec.rb337
-rw-r--r--spec/models/concerns/issuable_spec.rb26
2 files changed, 192 insertions, 171 deletions
diff --git a/spec/features/issues/filter_by_labels_spec.rb b/spec/features/issues/filter_by_labels_spec.rb
index 27d9ea7c62f..b189a97fbc0 100644
--- a/spec/features/issues/filter_by_labels_spec.rb
+++ b/spec/features/issues/filter_by_labels_spec.rb
@@ -1,170 +1,167 @@
-# Uncomment once this is merged with multi-filter-labels
-# Changes are related to using AND in label filters instead of OR
-
-# 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 not show "Bugfix1" or "Feature1" in issues list' do
-# expect(page).not_to have_content "Bugfix1"
-# expect(page).not_to have_content "Feature1"
-# 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 and 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" in issues list' do
-# expect(page).to have_content "Bugfix2"
-# 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
+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 not show "Bugfix1" or "Feature1" in issues list' do
+ expect(page).not_to have_content "Bugfix1"
+ expect(page).not_to have_content "Feature1"
+ 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 and 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" in issues list' do
+ expect(page).to have_content "Bugfix2"
+ 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/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb
index b16ccc6e305..dc7a9a10893 100644
--- a/spec/models/concerns/issuable_spec.rb
+++ b/spec/models/concerns/issuable_spec.rb
@@ -212,4 +212,28 @@ describe Issue, "Issuable" do
expect(issue.downvotes).to eq(1)
end
end
-end
+
+ describe ".with_label" do
+ let(:example_label) { 'test1' }
+ let(:example_labels) { ['test1', 'test2'] }
+
+ it 'finds issue with 1 label' do
+ setup_labels([example_label])
+
+ expect(Issue.with_label(example_label).count).to eq(1)
+ end
+
+ it 'finds issue with 2 labels' do
+ setup_labels(example_labels)
+
+ expect(Issue.with_label(example_labels).to_a.count).to eq(1)
+ end
+
+ def setup_labels(label_names)
+ labels = label_names.map do |label|
+ create(:label, project: issue.project, title: label)
+ end
+ issue.labels << labels
+ end
+ end
+end \ No newline at end of file