Commit e8a83cdc authored by Thong Kuah's avatar Thong Kuah

Make subgroup specs :nested_groups

Subgroups are not supported in mySQL. I changed Namespace#root_ancestor
to return from self_and_ancestors as a bugfix.

```
  184   # Returns all the ancestors of the current namespaces
  185   def ancestors
  186     return self.class.none unless parent_id
  187
  188     Gitlab::GroupHierarchy
  189       .new(self.class.where(id: parent_id))
  190       .base_and_ancestors
  191   end
```

So it seems like on mySQL we accidentally returned the parent group :

```
ancestors = self.class.where(id: parent_id)
ancestors.reorder(nil).find_by(parent_id: nil)
```

Project#root_namespace is used only by shared_runners_limit_namespace
and all the tests for shared_runner_minutes_on_root_namespace are only
enabled on `:nested_groups`

`when :shared_runner_minutes_on_root_namespace is enabled', :nested_groups`

We very clearly state in https://docs.gitlab.com/ee/user/group/subgroups/ that `
Nested groups are only supported when you use PostgreSQL`, so I think I
will fix forward and add `:nested_groups` to the two failing feature
specs.
parent f289952c
require 'spec_helper'
describe 'IDE', :js do
describe 'sub-groups' do
describe 'sub-groups', :nested_groups do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:subgroup) { create(:group, parent: group) }
......
......@@ -277,7 +277,7 @@ describe 'Project' do
end
end
context 'for subgroups', :js do
context 'for subgroups', :js, :nested_groups do
let(:group) { create(:group) }
let(:subgroup) { create(:group, parent: group) }
let(:project) { create(:project, :repository, group: subgroup) }
......
......@@ -3834,9 +3834,9 @@ describe Project do
subject { project.root_namespace }
context 'when namespace has parent group' do
context 'when namespace has parent group', :nested_groups do
let(:root_ancestor) { create(:group) }
let(:parent) { build(:group, parent: root_ancestor) }
let(:parent) { create(:group, parent: root_ancestor) }
it 'returns root ancestor' do
is_expected.to eq(root_ancestor)
......@@ -3844,7 +3844,7 @@ describe Project do
end
context 'when namespace is root ancestor' do
let(:parent) { build(:group) }
let(:parent) { create(:group) }
it 'returns current namespace' do
is_expected.to eq(parent)
......
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