From 8508811e000c5075ef26fa246ea51e9d88d72695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20J=C3=A4ggi?= Date: Mon, 24 Feb 2025 15:53:58 +0100 Subject: [PATCH] Require person_add_requests on all groups (#106) --- .../group/person_add_requests_controller.rb | 14 ++++++++++ .../group/person_add_requests/index.html.haml | 9 +++++++ ...3234_require_add_requests_on_all_groups.rb | 10 +++++++ lib/hitobito_jubla/wagon.rb | 1 + .../person_add_requests_controller_spec.rb | 26 +++++++++++++++++++ 5 files changed, 60 insertions(+) create mode 100644 app/controllers/jubla/group/person_add_requests_controller.rb create mode 100644 app/views/group/person_add_requests/index.html.haml create mode 100644 db/migrate/20250219083234_require_add_requests_on_all_groups.rb create mode 100644 spec/controllers/group/person_add_requests_controller_spec.rb diff --git a/app/controllers/jubla/group/person_add_requests_controller.rb b/app/controllers/jubla/group/person_add_requests_controller.rb new file mode 100644 index 00000000..0dc07c27 --- /dev/null +++ b/app/controllers/jubla/group/person_add_requests_controller.rb @@ -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 diff --git a/app/views/group/person_add_requests/index.html.haml b/app/views/group/person_add_requests/index.html.haml new file mode 100644 index 00000000..7a3c648d --- /dev/null +++ b/app/views/group/person_add_requests/index.html.haml @@ -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' \ No newline at end of file diff --git a/db/migrate/20250219083234_require_add_requests_on_all_groups.rb b/db/migrate/20250219083234_require_add_requests_on_all_groups.rb new file mode 100644 index 00000000..f06e94b2 --- /dev/null +++ b/db/migrate/20250219083234_require_add_requests_on_all_groups.rb @@ -0,0 +1,10 @@ +class RequireAddRequestsOnAllGroups < ActiveRecord::Migration[7.1] + def up + execute "UPDATE groups SET require_person_add_requests = TRUE" + change_column_default :groups, :require_person_add_requests, true + end + + def down + change_column_default :groups, :require_person_add_requests, false + end +end diff --git a/lib/hitobito_jubla/wagon.rb b/lib/hitobito_jubla/wagon.rb index 3ca3c209..9ded4561 100644 --- a/lib/hitobito_jubla/wagon.rb +++ b/lib/hitobito_jubla/wagon.rb @@ -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 diff --git a/spec/controllers/group/person_add_requests_controller_spec.rb b/spec/controllers/group/person_add_requests_controller_spec.rb new file mode 100644 index 00000000..f10f4438 --- /dev/null +++ b/spec/controllers/group/person_add_requests_controller_spec.rb @@ -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 \ No newline at end of file