Skip to content

Commit

Permalink
Require person_add_requests on all groups (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
njaeggi committed Feb 19, 2025
1 parent 62e63ee commit bfa63e7
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/controllers/jubla/group/person_add_requests_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) 2012-2013, Jungwacht Blauring Schweiz. This file is part of
# hitobito_jubla and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_jubla.

module Jubla::Group::PersonAddRequestsController
def activate
raise "shall never get called with jubla wagon"
end

def deactivate
raise "shall never get called with jubla wagon"
end
end
6 changes: 6 additions & 0 deletions app/models/jubla/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,10 @@ def alumni_filter_chain
role_types: self.class.roles.collect(&:sti_name)
}}
end

def require_person_add_requests
true
end

alias_method :require_person_add_requests?, :require_person_add_requests
end
9 changes: 9 additions & 0 deletions app/views/group/person_add_requests/index.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-# Copyright (c) 2012-2013, Jungwacht Blauring Schweiz. This file is part of
-# hitobito_jubla and licensed under the Affero General Public License version 3
-# or later. See the COPYING file at the top-level directory or at
-# https://github.com/hitobito/hitobito_jubla.
= render 'list'

- if can?(:activate_person_add_requests, @group)
= render 'approvers'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RequireAddRequestsOnAllGroups < ActiveRecord::Migration[7.1]
def change
execute "UPDATE groups SET require_person_add_requests = TRUE"
end
end
1 change: 1 addition & 0 deletions lib/hitobito_jubla/wagon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class Wagon < Rails::Engine

GroupsController.include Jubla::GroupsController
EventsController.include Jubla::EventsController
Group::PersonAddRequestsController.prepend Jubla::Group::PersonAddRequestsController
Event::ApplicationMarketController.include Jubla::Event::ApplicationMarketController
Event::QualificationsController.include Jubla::Event::QualificationsController
Event::RegisterController.include Jubla::Event::RegisterController
Expand Down
26 changes: 26 additions & 0 deletions spec/controllers/group/person_add_requests_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright (c) 2012-2013, Jungwacht Blauring Schweiz. This file is part of
# hitobito_jubla and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_jubla.

require "spec_helper"

describe Group::PersonAddRequestsController do
before { sign_in(people(:top_leader)) }

describe "#POST activate" do
it "raises" do
expect do
post :activate, params: { group_id: groups(:ch).id }
end.to raise_error "shall never get called with jubla wagon"
end
end

describe "#DELETE deactivate" do
it "raises" do
expect do
delete :deactivate, params: { group_id: groups(:ch).id }
end.to raise_error "shall never get called with jubla wagon"
end
end
end

0 comments on commit bfa63e7

Please sign in to comment.