Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-04-21 16:13:10 +0300
committerDouwe Maan <douwe@gitlab.com>2016-04-21 16:13:10 +0300
commit7ded28ff99d89d2ba51a522992f048ed446b4ce3 (patch)
tree620271393a0b8e2d2fe110db9367ffe7a76547b5 /spec/models
parent53534682a30f7eff0f52f5e8f6bbef95e321ec07 (diff)
parentb09b175def7c66487d4571d90f23f613d868f25c (diff)
Merge branch 'fix/label-filters' into 'master'
Filter labels by including ALL filter titles Fixed query to use `AND` and not `OR`. Refactored relevant specs See merge request !3815
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/concerns/issuable_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb
index b16ccc6e305..4a4cd093435 100644
--- a/spec/models/concerns/issuable_spec.rb
+++ b/spec/models/concerns/issuable_spec.rb
@@ -212,4 +212,34 @@ describe Issue, "Issuable" do
expect(issue.downvotes).to eq(1)
end
end
+
+ describe ".with_label" do
+ let(:project) { create(:project, :public) }
+ let(:bug) { create(:label, project: project, title: 'bug') }
+ let(:feature) { create(:label, project: project, title: 'feature') }
+ let(:enhancement) { create(:label, project: project, title: 'enhancement') }
+ let(:issue1) { create(:issue, title: "Bugfix1", project: project) }
+ let(:issue2) { create(:issue, title: "Bugfix2", project: project) }
+ let(:issue3) { create(:issue, title: "Feature1", project: project) }
+
+ before(:each) do
+ issue1.labels << bug
+ issue1.labels << feature
+ issue2.labels << bug
+ issue2.labels << enhancement
+ issue3.labels << feature
+ end
+
+ it 'finds the correct issue containing just enhancement label' do
+ expect(Issue.with_label(enhancement.title)).to match_array([issue2])
+ end
+
+ it 'finds the correct issues containing the same label' do
+ expect(Issue.with_label(bug.title)).to match_array([issue1, issue2])
+ end
+
+ it 'finds the correct issues containing only both labels' do
+ expect(Issue.with_label([bug.title, enhancement.title])).to match_array([issue2])
+ end
+ end
end