Commit 4d6d1f05 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'unify-some-models' into 'master'

CE:  Move some EE only codes in models to their EE modules

See merge request gitlab-org/gitlab-ce!20160
parents 955f0ea5 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
......
...@@ -24,7 +24,7 @@ class ProjectTeam ...@@ -24,7 +24,7 @@ class ProjectTeam
end end
def add_role(user, role, current_user: nil) def add_role(user, role, current_user: nil)
send(:"add_#{role}", user, current_user: current_user) # rubocop:disable GitlabSecurity/PublicSend public_send(:"add_#{role}", user, current_user: current_user) # rubocop:disable GitlabSecurity/PublicSend
end end
def find_member(user_id) def find_member(user_id)
......
...@@ -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) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment