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:
authorJacopo <beschi.jacopo@gmail.com>2018-10-29 12:50:18 +0300
committerJacopo <beschi.jacopo@gmail.com>2018-11-23 18:11:52 +0300
commitc068ac67b3e40fdc039c80372306f9cc3360d594 (patch)
treed707871f8b7f5deb7f62d7630f317e94946eb1cc /spec/finders
parentf0630090aaea98daef3582bc95efe3a43736a10f (diff)
Filter by `None`/`Any` for labels in issues/mrs API
By using the parameters `?labels=None|Any` the user can filter issues/mrs from the API that has `none/any` label. Affected endpoints are: - /api/issues - /api/projects/:id/issues - /api/groups/:id/issues - /api/merge_requests - /api/projects/:id/merge_requests - /api/groups/:id/merge_requests
Diffstat (limited to 'spec/finders')
-rw-r--r--spec/finders/issues_finder_spec.rb36
1 files changed, 34 insertions, 2 deletions
diff --git a/spec/finders/issues_finder_spec.rb b/spec/finders/issues_finder_spec.rb
index c0488c83bd8..515f6f70b99 100644
--- a/spec/finders/issues_finder_spec.rb
+++ b/spec/finders/issues_finder_spec.rb
@@ -256,19 +256,51 @@ describe IssuesFinder do
create(:label_link, label: label2, target: issue2)
end
- it 'returns the unique issues with any of those labels' do
+ it 'returns the unique issues with all those labels' do
+ expect(issues).to contain_exactly(issue2)
+ end
+ end
+
+ context 'filtering by a label that includes any or none in the title' do
+ let(:params) { { label_name: [label.title, label2.title].join(',') } }
+ let(:label) { create(:label, title: 'any foo', project: project2) }
+ let(:label2) { create(:label, title: 'bar none', project: project2) }
+
+ it 'returns the unique issues with all those labels' do
+ create(:label_link, label: label2, target: issue2)
+
expect(issues).to contain_exactly(issue2)
end
end
context 'filtering by no label' do
- let(:params) { { label_name: Label::None.title } }
+ let(:params) { { label_name: described_class::FILTER_NONE } }
it 'returns issues with no labels' do
expect(issues).to contain_exactly(issue1, issue3, issue4)
end
end
+ context 'filtering by legacy No+Label' do
+ let(:params) { { label_name: Label::NONE } }
+
+ it 'returns issues with no labels' do
+ expect(issues).to contain_exactly(issue1, issue3, issue4)
+ end
+ end
+
+ context 'filtering by any label' do
+ let(:params) { { label_name: described_class::FILTER_ANY } }
+
+ it 'returns issues that have one or more label' do
+ 2.times do
+ create(:label_link, label: create(:label, project: project2), target: issue3)
+ end
+
+ expect(issues).to contain_exactly(issue2, issue3)
+ end
+ end
+
context 'filtering by issue term' do
let(:params) { { search: 'git' } }