Commit d00cb00d authored by Robert Speicher's avatar Robert Speicher

Rename NoMilestone to Milestone::None

Also refactors IssuableFinder to avoid redundant title check.
parent cfd81340
......@@ -10,7 +10,7 @@
# state: 'open' or 'closed' or 'all'
# group_id: integer
# project_id: integer
# milestone_id: integer
# milestone_title: string
# assignee_id: integer
# search: string
# label_name: string
......@@ -76,7 +76,7 @@ class IssuableFinder
return @milestones if defined?(@milestones)
@milestones =
if milestones? && params[:milestone_title] != NoMilestone.title
if milestones? && params[:milestone_title] != Milestone::None.title
Milestone.where(title: params[:milestone_title])
else
nil
......@@ -183,12 +183,7 @@ class IssuableFinder
def by_milestone(items)
if milestones?
# `milestone_title` will still be present when "No Milestone" is selected
if params[:milestone_title] != NoMilestone.title
items = items.where(milestone_id: milestones.try(:pluck, :id))
else
items = items.where(milestone_id: NoMilestone.id)
end
end
items
......
......@@ -29,7 +29,7 @@ module MilestonesHelper
end.active
grouped_milestones = Milestones::GroupService.new(milestones).execute
grouped_milestones.unshift(NoMilestone)
grouped_milestones.unshift(Milestone::None)
options_from_collection_for_select(grouped_milestones, 'title', 'title', params[:milestone_title])
end
......
......@@ -14,6 +14,10 @@
#
class Milestone < ActiveRecord::Base
# Represents a "No Milestone" state used for filtering Issues and Merge
# Requests that have no milestone assigned.
None = Struct.new(:title).new('No Milestone')
include InternalId
include Sortable
......
# NoMilestone
#
# Represents a "No Milestone" state used for filtering Issues and Merge Requests
# that have no milestone assigned.
class NoMilestone
def self.id
nil
end
def self.title
'No Milestone'
end
end
......@@ -13,7 +13,7 @@ feature 'Issue filtering by Milestone' do
create(:issue, project: project)
visit_issues
filter_by_milestone(NoMilestone.title)
filter_by_milestone(Milestone::None.title)
expect(page).to have_css('.issue-title', count: 1)
end
......
......@@ -13,7 +13,7 @@ feature 'Merge Request filtering by Milestone' do
create(:merge_request, :simple, source_project: project)
visit_merge_requests
filter_by_milestone(NoMilestone.title)
filter_by_milestone(Milestone::None.title)
expect(page).to have_css('.merge-request-title', count: 1)
end
......
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