BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
4d791599
Commit
4d791599
authored
Oct 13, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure we always return an array of hierarchies
Even when we pass an array of only a single object
parent
a1bfdf76
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
1 deletion
+21
-1
group_child_serializer.rb
app/serializers/group_child_serializer.rb
+3
-1
children_controller_spec.rb
spec/controllers/groups/children_controller_spec.rb
+9
-0
group_child_serializer_spec.rb
spec/serializers/group_child_serializer_spec.rb
+9
-0
No files found.
app/serializers/group_child_serializer.rb
View file @
4d791599
...
...
@@ -28,7 +28,9 @@ class GroupChildSerializer < BaseSerializer
represent_hierarchy
(
children
.
hierarchy
(
hierarchy_root
),
opts
).
first
else
hierarchies
=
GroupDescendant
.
build_hierarchy
(
children
,
hierarchy_root
)
represent_hierarchy
(
hierarchies
,
opts
)
# When an array was passed, we always want to represent an array.
# Even if the hierarchy only contains one element
represent_hierarchy
(
Array
.
wrap
(
hierarchies
),
opts
)
end
end
...
...
spec/controllers/groups/children_controller_spec.rb
View file @
4d791599
...
...
@@ -141,6 +141,15 @@ describe Groups::ChildrenController do
expect
(
response
).
to
have_http_status
(
200
)
end
it
'returns an array with one element when only one result is matched'
do
create
(
:project
,
:public
,
namespace:
group
,
name:
'match'
)
get
:index
,
group_id:
group
.
to_param
,
filter:
'match'
,
format: :json
expect
(
json_response
).
to
be_kind_of
(
Array
)
expect
(
json_response
.
size
).
to
eq
(
1
)
end
it
'returns an empty array when there are no search results'
do
subgroup
=
create
(
:group
,
:public
,
parent:
group
)
l2_subgroup
=
create
(
:group
,
:public
,
parent:
subgroup
)
...
...
spec/serializers/group_child_serializer_spec.rb
View file @
4d791599
...
...
@@ -95,6 +95,15 @@ describe GroupChildSerializer do
expect
(
project1_json
[
:id
]).
to
eq
(
project1
.
id
)
expect
(
project2_json
[
:id
]).
to
eq
(
project2
.
id
)
end
it
'returns an array when an array of a single instance was given'
do
project
=
create
(
:project
,
namespace:
parent
)
json
=
serializer
.
represent
([
project
])
expect
(
json
).
to
be_kind_of
(
Array
)
expect
(
json
.
size
).
to
eq
(
1
)
end
end
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