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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
9176ea99
Commit
9176ea99
authored
Sep 21, 2018
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move group labels AR code into finder
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
e18d8d59
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
4 deletions
+51
-4
app/controllers/groups/labels_controller.rb
app/controllers/groups/labels_controller.rb
+1
-4
app/finders/group_labels_finder.rb
app/finders/group_labels_finder.rb
+17
-0
spec/finders/group_labels_finder_spec.rb
spec/finders/group_labels_finder_spec.rb
+33
-0
No files found.
app/controllers/groups/labels_controller.rb
View file @
9176ea99
...
...
@@ -10,10 +10,7 @@ class Groups::LabelsController < Groups::ApplicationController
def
index
respond_to
do
|
format
|
format
.
html
do
@labels
=
@group
.
labels
.
optionally_search
(
params
[
:search
])
.
order_by
(
sort
)
.
page
(
params
[
:page
])
@labels
=
GroupLabelsFinder
.
new
(
@group
,
params
.
merge
(
sort:
sort
)).
execute
end
format
.
json
do
render
json:
LabelSerializer
.
new
.
represent_appearance
(
available_labels
)
...
...
app/finders/group_labels_finder.rb
0 → 100644
View file @
9176ea99
# frozen_string_literal: true
class
GroupLabelsFinder
attr_reader
:group
,
:params
def
initialize
(
group
,
params
=
{})
@group
=
group
@params
=
params
end
def
execute
group
.
labels
.
optionally_search
(
params
[
:search
])
.
order_by
(
params
[
:sort
])
.
page
(
params
[
:page
])
end
end
spec/finders/group_labels_finder_spec.rb
0 → 100644
View file @
9176ea99
# frozen_string_literal: true
require
'spec_helper'
describe
GroupLabelsFinder
,
'#execute'
do
let!
(
:group
)
{
create
(
:group
)
}
let!
(
:label1
)
{
create
(
:group_label
,
title:
'Foo'
,
description:
'Lorem ipsum'
,
group:
group
)
}
let!
(
:label2
)
{
create
(
:group_label
,
title:
'Bar'
,
description:
'Fusce consequat'
,
group:
group
)
}
it
'returns all group labels sorted by name if no params'
do
result
=
described_class
.
new
(
group
).
execute
expect
(
result
.
to_a
).
to
match_array
([
label2
,
label1
])
end
it
'returns all group labels sorted by name desc'
do
result
=
described_class
.
new
(
group
,
sort:
'name_desc'
).
execute
expect
(
result
.
to_a
).
to
match_array
([
label2
,
label1
])
end
it
'returns group labels that march search'
do
result
=
described_class
.
new
(
group
,
search:
'Foo'
).
execute
expect
(
result
.
to_a
).
to
match_array
([
label1
])
end
it
'returns second page of labels'
do
result
=
described_class
.
new
(
group
,
page:
'2'
).
execute
expect
(
result
.
to_a
).
to
match_array
([])
end
end
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