diff --git a/app/services/groups/create_service.rb b/app/services/groups/create_service.rb index 9a630aee6269fe203b5ffa32efe8952b6561a029..febeb661fb5f3bb5622a5c06591e19d223dde4df 100644 --- a/app/services/groups/create_service.rb +++ b/app/services/groups/create_service.rb @@ -12,17 +12,11 @@ module Groups return @group end - parent_id = params[:parent_id] + if @group.parent && !can?(current_user, :admin_group, @group.parent) + @group.parent = nil + @group.errors.add(:parent_id, 'manage access required to create subgroup') - if parent_id - parent = Group.find(parent_id) - - unless can?(current_user, :admin_group, parent) - @group.parent_id = nil - @group.errors.add(:parent_id, 'manage access required to create subgroup') - - return @group - end + return @group end @group.name ||= @group.path.dup diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml index a3cd333373ecc6c483470917abb0109291851acd..9ef88f233c54d1d84124abcd2108f491ad022c48 100644 --- a/app/views/groups/show.html.haml +++ b/app/views/groups/show.html.haml @@ -35,7 +35,7 @@ - if @nested_groups.present? %li = link_to "#groups", 'data-toggle' => 'tab' do - Nested Groups + Subgroups .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 @@ -55,5 +55,4 @@ - if @nested_groups.present? .tab-pane#groups %ul.content-list - - @nested_groups.each do |group| - = render 'shared/groups/group', group: group + = render partial: 'shared/groups/group', collection: @nested_groups diff --git a/spec/features/groups_spec.rb b/spec/features/groups_spec.rb index d865a71f04bdc9dd897ba9cda857da7059b07c64..a515c92db3795da7a8ba8031a2a054d2a71614ea 100644 --- a/spec/features/groups_spec.rb +++ b/spec/features/groups_spec.rb @@ -115,7 +115,7 @@ feature 'Group', feature: true do it 'has nested groups tab with nested groups inside' do visit path - click_link 'Nested Groups' + click_link 'Subgroups' expect(page).to have_content(nested_group.full_name) end