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
d5a1910f
Commit
d5a1910f
authored
Jun 26, 2018
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port Namespace#root_ancestor to CE
parent
2024522b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
app/models/namespace.rb
app/models/namespace.rb
+4
-0
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+13
-0
No files found.
app/models/namespace.rb
View file @
d5a1910f
...
@@ -228,6 +228,10 @@ class Namespace < ActiveRecord::Base
...
@@ -228,6 +228,10 @@ class Namespace < ActiveRecord::Base
parent
.
present?
parent
.
present?
end
end
def
root_ancestor
ancestors
.
reorder
(
nil
).
find_by
(
parent_id:
nil
)
end
def
subgroup?
def
subgroup?
has_parent?
has_parent?
end
end
...
...
spec/models/namespace_spec.rb
View file @
d5a1910f
...
@@ -655,6 +655,19 @@ describe Namespace do
...
@@ -655,6 +655,19 @@ describe Namespace do
end
end
end
end
describe
'#root_ancestor'
do
it
'returns the top most ancestor'
,
:nested_groups
do
root_group
=
create
(
:group
)
nested_group
=
create
(
:group
,
parent:
root_group
)
deep_nested_group
=
create
(
:group
,
parent:
nested_group
)
very_deep_nested_group
=
create
(
:group
,
parent:
deep_nested_group
)
expect
(
nested_group
.
root_ancestor
).
to
eq
(
root_group
)
expect
(
deep_nested_group
.
root_ancestor
).
to
eq
(
root_group
)
expect
(
very_deep_nested_group
.
root_ancestor
).
to
eq
(
root_group
)
end
end
describe
'#remove_exports'
do
describe
'#remove_exports'
do
let
(
:legacy_project
)
{
create
(
:project
,
:with_export
,
:legacy_storage
,
namespace:
namespace
)
}
let
(
:legacy_project
)
{
create
(
:project
,
:with_export
,
:legacy_storage
,
namespace:
namespace
)
}
let
(
:hashed_project
)
{
create
(
:project
,
:with_export
,
namespace:
namespace
)
}
let
(
:hashed_project
)
{
create
(
:project
,
:with_export
,
namespace:
namespace
)
}
...
...
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