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
...
@@ -268,17 +268,19 @@ class IssuableFinder
end
end
def
by_weight
(
items
)
def
by_weight
(
items
)
return
items
if
filter_by_any_weight?
||
!
weights?
return
items
unless
weights?
if
filter_by_no_weight?
if
filter_by_no_weight?
items
.
where
(
weight:
[
-
1
,
nil
])
items
.
where
(
weight:
[
-
1
,
nil
])
elsif
filter_by_any_weight?
items
.
where
.
not
(
weight:
[
-
1
,
nil
])
else
else
items
.
where
(
weight:
params
[
:weight
])
items
.
where
(
weight:
params
[
:weight
])
end
end
end
end
def
weights?
def
weights?
params
[
:weight
].
present?
params
[
:weight
].
present?
&&
params
[
:weight
]
!=
Issue
::
WEIGHT_ALL
end
end
def
filter_by_no_weight?
def
filter_by_no_weight?
...
...
app/helpers/issues_helper.rb
View file @
2a37a929
...
@@ -144,12 +144,12 @@ module IssuesHelper
...
@@ -144,12 +144,12 @@ module IssuesHelper
end
end
def
issues_weight_options_for_edit
(
selected
=
nil
)
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
])
options_for_select
(
weights
,
selected
||
params
[
:weight
])
end
end
def
issue_weights
def
issue_weights
(
weight_array
=
Issue
.
weight_options
)
Issue
.
weight_options
.
map
{
|
op
|
[
op
]
*
2
}
weight_array
.
map
{
|
op
|
[
op
]
*
2
}
end
end
# Required for Banzai::Filter::IssueReferenceFilter
# Required for Banzai::Filter::IssueReferenceFilter
module_function
:url_for_issue
module_function
:url_for_issue
...
...
app/models/issue.rb
View file @
2a37a929
...
@@ -30,6 +30,7 @@ class Issue < ActiveRecord::Base
...
@@ -30,6 +30,7 @@ class Issue < ActiveRecord::Base
include
Elastic
::
IssuesSearch
include
Elastic
::
IssuesSearch
WEIGHT_RANGE
=
1
..
9
WEIGHT_RANGE
=
1
..
9
WEIGHT_ALL
=
'Everything'
WEIGHT_ANY
=
'Any Weight'
WEIGHT_ANY
=
'Any Weight'
WEIGHT_NONE
=
'No Weight'
WEIGHT_NONE
=
'No Weight'
...
@@ -127,6 +128,6 @@ class Issue < ActiveRecord::Base
...
@@ -127,6 +128,6 @@ class Issue < ActiveRecord::Base
end
end
def
self
.
weight_options
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
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
...
@@ -4,13 +4,12 @@ feature 'Issue filtering by Weight', feature: true do
include
Select2Helper
include
Select2Helper
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:weight
)
{
create
(
:weight
,
project:
project
)
}
let
(
:weight_num
)
{
random_weight
}
let
(
:weight_num
)
{
random_weight
}
before
(
:each
)
do
before
(
:each
)
do
create
(
:issue
,
project:
project
,
weight:
nil
)
create
(
:issue
,
project:
project
,
weight:
nil
)
create
(
:issue
,
project:
project
,
weight:
weight_num
)
create
(
:issue
,
project:
project
,
weight:
weight_num
)
create
(
:issue
,
project:
project
,
weight:
random_weight
)
create
(
:issue
,
project:
project
,
weight:
weight_num
)
end
end
scenario
'filters by no Weight'
,
js:
true
do
scenario
'filters by no Weight'
,
js:
true
do
...
@@ -24,14 +23,21 @@ feature 'Issue filtering by Weight', feature: true do
...
@@ -24,14 +23,21 @@ 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:
3
)
expect
(
page
).
to
have_css
(
'.issue'
,
count:
2
)
end
end
scenario
'filters by a specific Weight'
,
js:
true
do
scenario
'filters by a specific Weight'
,
js:
true
do
visit_issues
(
project
)
visit_issues
(
project
)
filter_by_weight
(
weight_num
)
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
end
def
visit_issues
(
project
)
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