Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
2a37a929
Commit
2a37a929
authored
Feb 23, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored weight stuff and added new option to select all weight
parent
21ba6790
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
10 deletions
+19
-10
app/finders/issuable_finder.rb
app/finders/issuable_finder.rb
+4
-2
app/helpers/issues_helper.rb
app/helpers/issues_helper.rb
+3
-3
app/models/issue.rb
app/models/issue.rb
+2
-1
spec/features/issues/filter_by_weight_spec.rb
spec/features/issues/filter_by_weight_spec.rb
+10
-4
No files found.
app/finders/issuable_finder.rb
View file @
2a37a929
...
...
@@ -268,17 +268,19 @@ class IssuableFinder
end
def
by_weight
(
items
)
return
items
if
filter_by_any_weight?
||
!
weights?
return
items
unless
weights?
if
filter_by_no_weight?
items
.
where
(
weight:
[
-
1
,
nil
])
elsif
filter_by_any_weight?
items
.
where
.
not
(
weight:
[
-
1
,
nil
])
else
items
.
where
(
weight:
params
[
:weight
])
end
end
def
weights?
params
[
:weight
].
present?
params
[
:weight
].
present?
&&
params
[
:weight
]
!=
Issue
::
WEIGHT_ALL
end
def
filter_by_no_weight?
...
...
app/helpers/issues_helper.rb
View file @
2a37a929
...
...
@@ -144,12 +144,12 @@ module IssuesHelper
end
def
issues_weight_options_for_edit
(
selected
=
nil
)
weights
=
issue_weights
-
[[
Issue
::
WEIGHT_ANY
]
*
2
]
weights
=
[[
Issue
::
WEIGHT_NONE
,
nil
]]
+
issue_weights
(
Issue
::
WEIGHT_RANGE
.
to_a
)
options_for_select
(
weights
,
selected
||
params
[
:weight
])
end
def
issue_weights
Issue
.
weight_options
.
map
{
|
op
|
[
op
]
*
2
}
def
issue_weights
(
weight_array
=
Issue
.
weight_options
)
weight_array
.
map
{
|
op
|
[
op
]
*
2
}
end
# Required for Banzai::Filter::IssueReferenceFilter
module_function
:url_for_issue
...
...
app/models/issue.rb
View file @
2a37a929
...
...
@@ -30,6 +30,7 @@ class Issue < ActiveRecord::Base
include
Elastic
::
IssuesSearch
WEIGHT_RANGE
=
1
..
9
WEIGHT_ALL
=
'Everything'
WEIGHT_ANY
=
'Any Weight'
WEIGHT_NONE
=
'No Weight'
...
...
@@ -127,6 +128,6 @@ class Issue < ActiveRecord::Base
end
def
self
.
weight_options
[
WEIGHT_ANY
,
WEIGHT_NONE
]
+
WEIGHT_RANGE
.
to_a
[
WEIGHT_A
LL
,
WEIGHT_A
NY
,
WEIGHT_NONE
]
+
WEIGHT_RANGE
.
to_a
end
end
spec/features/issues/filter_by_weight_spec.rb
View file @
2a37a929
...
...
@@ -4,13 +4,12 @@ feature 'Issue filtering by Weight', feature: true do
include
Select2Helper
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:weight
)
{
create
(
:weight
,
project:
project
)
}
let
(
:weight_num
)
{
random_weight
}
before
(
:each
)
do
create
(
:issue
,
project:
project
,
weight:
nil
)
create
(
:issue
,
project:
project
,
weight:
weight_num
)
create
(
:issue
,
project:
project
,
weight:
random_weight
)
create
(
:issue
,
project:
project
,
weight:
weight_num
)
end
scenario
'filters by no Weight'
,
js:
true
do
...
...
@@ -24,14 +23,21 @@ feature 'Issue filtering by Weight', feature: true do
visit_issues
(
project
)
filter_by_weight
(
Issue
::
WEIGHT_ANY
)
expect
(
page
).
to
have_css
(
'.issue'
,
count:
3
)
expect
(
page
).
to
have_css
(
'.issue'
,
count:
2
)
end
scenario
'filters by a specific Weight'
,
js:
true
do
visit_issues
(
project
)
filter_by_weight
(
weight_num
)
expect
(
page
).
to
have_css
(
'.issue'
,
count:
1
)
expect
(
page
).
to
have_css
(
'.issue'
,
count:
2
)
end
scenario
'all weights'
,
js:
true
do
visit_issues
(
project
)
filter_by_weight
(
Issue
::
WEIGHT_ALL
)
expect
(
page
).
to
have_css
(
'.issue'
,
count:
3
)
end
def
visit_issues
(
project
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment