From 10de4e3bb612a529480c93da53849d95e98a8633 Mon Sep 17 00:00:00 2001
From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Date: Mon, 26 Dec 2016 12:51:48 +0200
Subject: [PATCH] Show nested groups tab on group page

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
---
 app/controllers/groups_controller.rb           |  2 ++
 app/views/groups/show.html.haml                | 10 ++++++++++
 changelogs/unreleased/dz-nested-group-misc.yml |  4 ++++
 spec/features/groups_spec.rb                   | 13 +++++++++++++
 4 files changed, 29 insertions(+)
 create mode 100644 changelogs/unreleased/dz-nested-group-misc.yml

diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index efe9c001bcf..e061df2f819 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -42,6 +42,8 @@ class GroupsController < Groups::ApplicationController
       @notification_setting = current_user.notification_settings_for(group)
     end
 
+    @nested_groups = group.children
+
     setup_projects
 
     respond_to do |format|
diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml
index 52ce26a20b1..a3cd333373e 100644
--- a/app/views/groups/show.html.haml
+++ b/app/views/groups/show.html.haml
@@ -32,6 +32,10 @@
         %li
           = link_to "#shared", 'data-toggle' => 'tab' do
             Shared Projects
+      - if @nested_groups.present?
+        %li
+          = link_to "#groups", 'data-toggle' => 'tab' do
+            Nested Groups
     .nav-controls
       = form_tag request.path, method: :get, class: 'project-filter-form', id: 'project-filter-form' do |f|
         = search_field_tag :filter_projects, nil, placeholder: 'Filter by name', class: 'projects-list-filter form-control', spellcheck: false
@@ -47,3 +51,9 @@
     - if @shared_projects.present?
       .tab-pane#shared
         = render "shared_projects", projects: @shared_projects
+
+    - if @nested_groups.present?
+      .tab-pane#groups
+        %ul.content-list
+          - @nested_groups.each do |group|
+            = render 'shared/groups/group', group: group
diff --git a/changelogs/unreleased/dz-nested-group-misc.yml b/changelogs/unreleased/dz-nested-group-misc.yml
new file mode 100644
index 00000000000..9c9d0b1c644
--- /dev/null
+++ b/changelogs/unreleased/dz-nested-group-misc.yml
@@ -0,0 +1,4 @@
+---
+title: Show nested groups tab on group page
+merge_request: 8308
+author:
diff --git a/spec/features/groups_spec.rb b/spec/features/groups_spec.rb
index 4b19886274e..d865a71f04b 100644
--- a/spec/features/groups_spec.rb
+++ b/spec/features/groups_spec.rb
@@ -107,4 +107,17 @@ feature 'Group', feature: true do
       expect(page).to have_css('.group-home-desc a[rel]')
     end
   end
+
+  describe 'group page with nested groups', js: true do
+    let!(:group) { create(:group) }
+    let!(:nested_group) { create(:group, parent: group) }
+    let!(:path)  { group_path(group) }
+
+    it 'has nested groups tab with nested groups inside' do
+      visit path
+      click_link 'Nested Groups'
+
+      expect(page).to have_content(nested_group.full_name)
+    end
+  end
 end
-- 
GitLab