diff options
author | Toon Claes <toon@gitlab.com> | 2017-06-13 10:11:33 +0300 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2017-06-15 09:46:34 +0300 |
commit | ef1811f4bc211929997a5b8cc1ecd511b52ca6f4 (patch) | |
tree | 01ca753274ade58376c6f081b83e53c456d1069f /spec/lib | |
parent | 42aaae9916b7b76da968579fcc722067947df018 (diff) |
Subgroups page should show groups authorized through inheritance
When a user is authorized to a group, they are also authorized to see all the
ancestor groups and descendant groups.
When a user is authorized to a project, they are authorized to see all the
ancestor groups too.
Closes #32135
See merge request !11764
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/group_hierarchy_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/lib/gitlab/group_hierarchy_spec.rb b/spec/lib/gitlab/group_hierarchy_spec.rb index 5d0ed1522b3..08010c2d0e2 100644 --- a/spec/lib/gitlab/group_hierarchy_spec.rb +++ b/spec/lib/gitlab/group_hierarchy_spec.rb @@ -17,6 +17,12 @@ describe Gitlab::GroupHierarchy, :postgresql do it 'includes all of the ancestors' do expect(relation).to include(parent, child1) end + + it 'uses ancestors_base #initialize argument' do + relation = described_class.new(Group.where(id: child2.id), Group.none).base_and_ancestors + + expect(relation).to include(parent, child1, child2) + end end describe '#base_and_descendants' do @@ -31,6 +37,12 @@ describe Gitlab::GroupHierarchy, :postgresql do it 'includes all the descendants' do expect(relation).to include(child1, child2) end + + it 'uses descendants_base #initialize argument' do + relation = described_class.new(Group.none, Group.where(id: parent.id)).base_and_descendants + + expect(relation).to include(parent, child1, child2) + end end describe '#all_groups' do @@ -49,5 +61,17 @@ describe Gitlab::GroupHierarchy, :postgresql do it 'includes the descendants' do expect(relation).to include(child2) end + + it 'uses ancestors_base #initialize argument for ancestors' do + relation = described_class.new(Group.where(id: child1.id), Group.where(id: Group.maximum(:id).succ)).all_groups + + expect(relation).to include(parent) + end + + it 'uses descendants_base #initialize argument for descendants' do + relation = described_class.new(Group.where(id: Group.maximum(:id).succ), Group.where(id: child1.id)).all_groups + + expect(relation).to include(child2) + end end end |