Commit 761e950c authored by James Lopez's avatar James Lopez

added new filters and fixed spec

parent e8b5d816
......@@ -268,11 +268,25 @@ class IssuableFinder
end
def by_weight(items)
if params[:weight].present?
items = items.where(weight: params[:weight])
return items if filter_by_any_weight? || !weights?
if filter_by_no_weight?
items.where(weight: [-1, nil])
else
items.where(weight: params[:weight])
end
end
items
def weights?
params[:weight].present?
end
def filter_by_no_weight?
params[:weight] == Issue::WEIGHT_NONE
end
def filter_by_any_weight?
params[:weight] == Issue::WEIGHT_ANY
end
def current_user_related?
......
......@@ -140,11 +140,7 @@ module IssuesHelper
end
def projects_weight_options(selected = nil)
options = (Issue::WEIGHT_RANGE).map do |i|
[i, i]
end
options.unshift(['Any', nil])
options = Issue.weight_options.map {|op| [op] * 2}
options_for_select(options, selected || params[:weight])
end
......
......@@ -24,7 +24,7 @@ feature 'Issue filtering by Weight', feature: true do
visit_issues(project)
filter_by_weight(Issue::WEIGHT_ANY)
expect(page).to have_css('.issue', count: 1)
expect(page).to have_css('.issue', count: 3)
end
scenario 'filters by a specific Weight', js: true do
......
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