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

added new filters and fixed spec

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