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
82f9957d
Commit
82f9957d
authored
Dec 13, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor Namespace#parents method
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
f8a17a38
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
12 deletions
+8
-12
namespace.rb
app/models/namespace.rb
+1
-11
namespace_spec.rb
spec/models/namespace_spec.rb
+7
-1
No files found.
app/models/namespace.rb
View file @
82f9957d
...
...
@@ -172,17 +172,7 @@ class Namespace < ActiveRecord::Base
end
def
parents
@parents
||=
begin
parents
=
[]
if
parent
parents
<<
parent
parents
+=
parent
.
parents
end
parents
end
@parents
||=
parent
?
parent
.
parents
+
[
parent
]
:
[]
end
private
...
...
spec/models/namespace_spec.rb
View file @
82f9957d
...
...
@@ -145,7 +145,13 @@ describe Namespace, models: true do
let
(
:group
)
{
create
(
:group
)
}
let
(
:nested_group
)
{
create
(
:group
,
parent:
group
)
}
let
(
:deep_nested_group
)
{
create
(
:group
,
parent:
nested_group
)
}
let
(
:very_deep_nested_group
)
{
create
(
:group
,
parent:
deep_nested_group
)
}
it
{
expect
(
deep_nested_group
.
parents
).
to
eq
([
nested_group
,
group
])
}
it
'returns the correct parents'
do
expect
(
very_deep_nested_group
.
parents
).
to
eq
([
group
,
nested_group
,
deep_nested_group
])
expect
(
deep_nested_group
.
parents
).
to
eq
([
group
,
nested_group
])
expect
(
nested_group
.
parents
).
to
eq
([
group
])
expect
(
group
.
parents
).
to
eq
([])
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