Skip to content
Snippets Groups Projects
Commit d5a1910f authored by Lin Jen-Shin's avatar Lin Jen-Shin
Browse files

Port Namespace#root_ancestor to CE

parent 2024522b
No related branches found
No related tags found
1 merge request!10495Merge Requests - Assignee
Loading
Loading
@@ -228,6 +228,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
Loading
Loading
Loading
Loading
@@ -655,6 +655,19 @@ 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 '#remove_exports' do
let(:legacy_project) { create(:project, :with_export, :legacy_storage, namespace: namespace) }
let(:hashed_project) { create(:project, :with_export, namespace: namespace) }
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment