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
Léo-Paul Géneau
gitlab-ce
Commits
d806230f
Commit
d806230f
authored
Dec 13, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add parents method to Namespace
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
5c06875c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
5 deletions
+28
-5
app/models/namespace.rb
app/models/namespace.rb
+20
-5
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+8
-0
No files found.
app/models/namespace.rb
View file @
d806230f
...
...
@@ -163,11 +163,26 @@ class Namespace < ActiveRecord::Base
end
def
full_name
if
parent
parent
.
full_name
+
' / '
+
name
else
name
end
@full_name
||=
if
parent
parent
.
full_name
+
' / '
+
name
else
name
end
end
def
parents
@parents
||=
begin
parents
=
[]
if
parent
parents
<<
parent
parents
+=
parent
.
parents
end
parents
end
end
private
...
...
spec/models/namespace_spec.rb
View file @
d806230f
...
...
@@ -132,4 +132,12 @@ describe Namespace, models: true do
it
{
expect
(
group
.
full_path
).
to
eq
(
group
.
path
)
}
it
{
expect
(
nested_group
.
full_path
).
to
eq
(
"
#{
group
.
path
}
/
#{
nested_group
.
path
}
"
)
}
end
describe
'#parents'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:nested_group
)
{
create
(
:group
,
parent:
group
)
}
let
(
:deep_nested_group
)
{
create
(
:group
,
parent:
nested_group
)
}
it
{
expect
(
deep_nested_group
.
parents
).
to
eq
([
nested_group
,
group
])
}
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