summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeinrich Lee Yu <hleeyu@gmail.com>2018-10-26 20:37:52 +0800
committerHeinrich Lee Yu <hleeyu@gmail.com>2018-11-01 07:39:45 +0800
commite5a09709ea7c3104d5aad141132caabde097e1b3 (patch)
tree55ca57b60fbeea214d54629c81c950801249be48
parent31733b6fc5a9ba4443a5dd279e787e2fd8e31c6d (diff)
downloadgitlab-ce-e5a09709ea7c3104d5aad141132caabde097e1b3.tar.gz
Update API to accept None and Any
-rw-r--r--app/finders/issuable_finder.rb26
-rw-r--r--spec/finders/issues_finder_spec.rb16
-rw-r--r--spec/requests/api/issues_spec.rb4
3 files changed, 29 insertions, 17 deletions
diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb
index 92aaa9c6b29..4dc8c8b8bb1 100644
--- a/app/finders/issuable_finder.rb
+++ b/app/finders/issuable_finder.rb
@@ -193,7 +193,19 @@ class IssuableFinder
end
def filter_by_no_milestone?
- milestones? && params[:milestone_title] == Milestone::None.title
+ [FILTER_NONE, Milestone::None.title].include?(params[:milestone_title].to_s.downcase)
+ end
+
+ def filter_by_any_milestone?
+ [FILTER_ANY, Milestone::Any.title].include?(params[:milestone_title].to_s.downcase)
+ end
+
+ def filter_by_upcoming_milestone?
+ params[:milestone_title] == Milestone::Upcoming.name
+ end
+
+ def filter_by_started_milestone?
+ params[:milestone_title] == Milestone::Started.name
end
def milestones
@@ -432,18 +444,6 @@ class IssuableFinder
end
# rubocop: enable CodeReuse/ActiveRecord
- def filter_by_upcoming_milestone?
- params[:milestone_title] == Milestone::Upcoming.name
- end
-
- def filter_by_any_milestone?
- params[:milestone_title] == Milestone::Any.title
- end
-
- def filter_by_started_milestone?
- params[:milestone_title] == Milestone::Started.name
- end
-
# rubocop: disable CodeReuse/ActiveRecord
def by_milestone(items)
if milestones?
diff --git a/spec/finders/issues_finder_spec.rb b/spec/finders/issues_finder_spec.rb
index 2f164ffa8b0..0b3e2709ade 100644
--- a/spec/finders/issues_finder_spec.rb
+++ b/spec/finders/issues_finder_spec.rb
@@ -144,19 +144,31 @@ describe IssuesFinder do
end
context 'filtering by no milestone' do
- let(:params) { { milestone_title: Milestone::None.title } }
+ let(:params) { { milestone_title: 'None' } }
it 'returns issues with no milestone' do
expect(issues).to contain_exactly(issue2, issue3, issue4)
end
+
+ it 'returns issues with no milestone (deprecated)' do
+ params[:milestone_title] = Milestone::None.title
+
+ expect(issues).to contain_exactly(issue2, issue3, issue4)
+ end
end
context 'filtering by any milestone' do
- let(:params) { { milestone_title: Milestone::Any.title } }
+ let(:params) { { milestone_title: 'Any' } }
it 'returns issues with any assigned milestone' do
expect(issues).to contain_exactly(issue1)
end
+
+ it 'returns issues with any assigned milestone (deprecated)' do
+ params[:milestone_title] = Milestone::Any.title
+
+ expect(issues).to contain_exactly(issue1)
+ end
end
context 'filtering by upcoming milestone' do
diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb
index 9cda39a569b..7813f6bc550 100644
--- a/spec/requests/api/issues_spec.rb
+++ b/spec/requests/api/issues_spec.rb
@@ -55,8 +55,8 @@ describe API::Issues do
end
let!(:note) { create(:note_on_issue, author: user, project: project, noteable: issue) }
- let(:no_milestone_title) { URI.escape(Milestone::None.title) }
- let(:any_milestone_title) { URI.escape(Milestone::Any.title) }
+ let(:no_milestone_title) { "None" }
+ let(:any_milestone_title) { "Any" }
before(:all) do
project.add_reporter(user)