Commit e5a09709 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Update API to accept None and Any

parent 31733b6f
...@@ -193,7 +193,19 @@ class IssuableFinder ...@@ -193,7 +193,19 @@ class IssuableFinder
end end
def filter_by_no_milestone? 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 end
def milestones def milestones
...@@ -432,18 +444,6 @@ class IssuableFinder ...@@ -432,18 +444,6 @@ class IssuableFinder
end end
# rubocop: enable CodeReuse/ActiveRecord # 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 # rubocop: disable CodeReuse/ActiveRecord
def by_milestone(items) def by_milestone(items)
if milestones? if milestones?
......
...@@ -144,19 +144,31 @@ describe IssuesFinder do ...@@ -144,19 +144,31 @@ describe IssuesFinder do
end end
context 'filtering by no milestone' do 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 it 'returns issues with no milestone' do
expect(issues).to contain_exactly(issue2, issue3, issue4) expect(issues).to contain_exactly(issue2, issue3, issue4)
end 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 end
context 'filtering by any milestone' do 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 it 'returns issues with any assigned milestone' do
expect(issues).to contain_exactly(issue1) expect(issues).to contain_exactly(issue1)
end end
it 'returns issues with any assigned milestone (deprecated)' do
params[:milestone_title] = Milestone::Any.title
expect(issues).to contain_exactly(issue1)
end
end end
context 'filtering by upcoming milestone' do context 'filtering by upcoming milestone' do
......
...@@ -55,8 +55,8 @@ describe API::Issues do ...@@ -55,8 +55,8 @@ describe API::Issues do
end end
let!(:note) { create(:note_on_issue, author: user, project: project, noteable: issue) } let!(:note) { create(:note_on_issue, author: user, project: project, noteable: issue) }
let(:no_milestone_title) { URI.escape(Milestone::None.title) } let(:no_milestone_title) { "None" }
let(:any_milestone_title) { URI.escape(Milestone::Any.title) } let(:any_milestone_title) { "Any" }
before(:all) do before(:all) do
project.add_reporter(user) project.add_reporter(user)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment