diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index 3abf00058..cf9820418 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -1,24 +1,6 @@ class Admin::GroupsController < Admin::ApplicationController after_action :verify_authorized - def new - @group = Group.new - authorize @group - end - - def create - @group = Group.new(group_params) - authorize @group - - if @group.save - flash[:notice] = "Group #{@group.name} for chapter #{@group.chapter.name} has been successfully created" - redirect_to [:admin, @group] - else - flash[:notice] = @group.errors.full_messages - render 'new' - end - end - def show @group = Group.find(params[:id]) authorize @group @@ -27,10 +9,4 @@ def show @total_count = @group.members.count @pagy, @members = pagy(Group.members_by_recent_rsvp(@group), items: 20) end - - private - - def group_params - params.expect(group: %i[name description chapter_id]) - end end diff --git a/app/policies/group_policy.rb b/app/policies/group_policy.rb index 5e3d40e70..984476220 100644 --- a/app/policies/group_policy.rb +++ b/app/policies/group_policy.rb @@ -1,8 +1,4 @@ class GroupPolicy < ApplicationPolicy - def create? - user.is_admin? - end - def show? admin_or_chapter_organiser? end diff --git a/app/views/admin/groups/new.html.haml b/app/views/admin/groups/new.html.haml deleted file mode 100644 index 1866a536d..000000000 --- a/app/views/admin/groups/new.html.haml +++ /dev/null @@ -1,13 +0,0 @@ -.container.py-4.py-lg-5 - .row.mb-4 - .col - %h1 New Group - - .row - .col.col-lg-8 - = simple_form_for [:admin, @group] do |f| - = f.input :name, label: 'Name', collection: Group::NAMES - = f.input :description, input_html: { rows: 3 } - = f.association :chapter, required: true - .text-right - = f.button :button, 'Create group', class: 'btn btn-primary' diff --git a/app/views/layouts/_admin_menu.html.haml b/app/views/layouts/_admin_menu.html.haml index d457a637b..67e469646 100644 --- a/app/views/layouts/_admin_menu.html.haml +++ b/app/views/layouts/_admin_menu.html.haml @@ -24,9 +24,6 @@ %li = link_to new_admin_chapter_path, class: 'dropdown-item' do New chapter -%li - = link_to new_admin_group_path, class: 'dropdown-item' do - New group %li = link_to admin_testimonials_path, class: 'dropdown-item' do Testimonials diff --git a/config/routes.rb b/config/routes.rb index ebcd1a730..41f128025 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -133,7 +133,7 @@ end resources :meeting_invitations, only: %i[create update] - resources :groups, only: %i[index new create show] + resources :groups, only: %i[show] resources :sponsors, except: [:destroy] resources :feedback, only: [:index] resources :contacts diff --git a/spec/features/admin/groups_spec.rb b/spec/features/admin/groups_spec.rb index 8785ff2a4..769d6c5ef 100644 --- a/spec/features/admin/groups_spec.rb +++ b/spec/features/admin/groups_spec.rb @@ -1,23 +1,4 @@ RSpec.feature 'admin groups', type: :feature do - describe '#creating a new group' do - let(:member) { Fabricate(:member) } - - before do - Fabricate(:chapter, name: 'Brighton') - login_as_admin(member) - end - - scenario 'an admin can create a new chapter' do - visit new_admin_group_path - - select 'Students', from: 'group[name]' - select 'Brighton', from: 'group[chapter_id]' - click_on 'Create group' - - expect(page).to have_text('Group Students for chapter Brighton has been successfully created') - end - end - describe '#show page' do let(:member) { Fabricate(:member) } let(:chapter) { Fabricate(:chapter, name: 'Brighton') } diff --git a/spec/policies/group_policy_spec.rb b/spec/policies/group_policy_spec.rb index 77b54223e..658a5280e 100644 --- a/spec/policies/group_policy_spec.rb +++ b/spec/policies/group_policy_spec.rb @@ -5,24 +5,6 @@ let(:admin) { Fabricate(:member).tap { |m| m.add_role(:admin) } } let(:regular_member) { Fabricate(:member) } - describe '#create?' do - context 'when user is admin' do - let(:user) { admin } - - it 'permits access' do - expect(policy.create?).to be true - end - end - - context 'when user is regular member' do - let(:user) { regular_member } - - it 'denies access' do - expect(policy.create?).to be false - end - end - end - describe '#show?' do context 'when user is admin' do let(:user) { admin }