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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
b17ae7fd
Commit
b17ae7fd
authored
Nov 21, 2017
by
Kamil Trzcinski
Committed by
ayufanpl
Nov 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use root_ancestor of Namespace (and move it from EE)
parent
7d2ea9aa
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
18 deletions
+22
-18
app/models/namespace.rb
app/models/namespace.rb
+4
-0
app/models/project.rb
app/models/project.rb
+5
-1
ee/app/models/ee/namespace.rb
ee/app/models/ee/namespace.rb
+0
-4
spec/ee/spec/models/ee/namespace_spec.rb
spec/ee/spec/models/ee/namespace_spec.rb
+0
-13
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+13
-0
No files found.
app/models/namespace.rb
View file @
b17ae7fd
...
...
@@ -213,6 +213,10 @@ class Namespace < ActiveRecord::Base
parent
.
present?
end
def
root_ancestor
ancestors
.
reorder
(
nil
).
find_by
(
parent_id:
nil
)
end
def
subgroup?
has_parent?
end
...
...
app/models/project.rb
View file @
b17ae7fd
...
...
@@ -501,7 +501,11 @@ class Project < ActiveRecord::Base
end
def
root_namespace
@root_namespace
||=
Gitlab
::
GroupHierarchy
.
new
(
Namespace
.
where
(
id:
namespace_id
)).
roots
.
take
if
namespace
.
has_parent?
namespace
.
root_ancestor
else
namespace
end
end
def
lfs_enabled?
...
...
ee/app/models/ee/namespace.rb
View file @
b17ae7fd
...
...
@@ -43,10 +43,6 @@ module EE
end
end
def
root_ancestor
ancestors
.
reorder
(
nil
).
find_by
(
parent_id:
nil
)
end
def
move_dir
raise
NotImplementedError
unless
defined?
(
super
)
...
...
spec/ee/spec/models/ee/namespace_spec.rb
View file @
b17ae7fd
...
...
@@ -363,19 +363,6 @@ describe Namespace do
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
'#actual_plan'
do
context
'when namespace has a plan associated'
do
before
do
...
...
spec/models/namespace_spec.rb
View file @
b17ae7fd
...
...
@@ -675,4 +675,17 @@ describe Namespace do
expect
(
other_namespace
.
find_fork_of
(
project
)).
to
eq
(
other_fork
)
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
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