Skip to content

Commit

Permalink
Bug/1476/redirect to self registration (#1476)
Browse files Browse the repository at this point in the history
* Add spec

* Redirect to self registration

* Fix rubocop
  • Loading branch information
njaeggi authored Jan 7, 2025
1 parent b2c7026 commit afd5784
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
10 changes: 4 additions & 6 deletions app/controllers/sac_cas/groups/self_inscription_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
module SacCas::Groups::SelfInscriptionController
extend ActiveSupport::Concern

def create
if person.years < 6
redirect_to group_self_inscription_path(group), alert: I18n.t("groups.self_inscription.must_be_six_years_old")
else
super
end
# always redirect to self registration, self inscription is currently not used in the sac wagon
# self registration is also possible for logged in users, so there is no need for self inscription
def show
redirect_to group_self_registration_path
end
end
1 change: 1 addition & 0 deletions lib/hitobito_sac_cas/wagon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ class Wagon < Rails::Engine
GroupsController.permitted_attrs << :mitglied_termination_by_section_only
GroupsController.permitted_attrs << {section_offering_ids: []}
Groups::SelfRegistrationController.prepend SacCas::Groups::SelfRegistrationController
Groups::SelfInscriptionController.prepend SacCas::Groups::SelfInscriptionController
JsonApi::EventsController.prepend SacCas::JsonApi::EventsController
MailingListsController.prepend SacCas::MailingListsController
PeopleController.permitted_attrs << :correspondence
Expand Down
18 changes: 18 additions & 0 deletions spec/controllers/groups/self_inscription_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

# Copyright (c) 2012-2024, Schweizer Alpen-Club. This file is part of
# hitobito_sac_cas 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_sac_cas.

require "spec_helper"

describe Groups::SelfInscriptionController do
let(:group) { groups(:bluemlisalp_neuanmeldungen_sektion) }

it "redirects to login" do
sign_in(people(:mitglied))
get :show, params: {group_id: group.id}
expect(response).to redirect_to group_self_registration_path
end
end

0 comments on commit afd5784

Please sign in to comment.