-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Align external event registration with basic login (#1409)
- Loading branch information
1 parent
5115e8d
commit a2ba120
Showing
4 changed files
with
101 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 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 | ||
|
||
module SacCas::Event::RegisterController | ||
def save_entry | ||
if super | ||
person.send_reset_password_instructions | ||
Group::AboBasicLogin::BasicLogin.create!(group: abo_basic_login_group, person: person) | ||
end | ||
end | ||
|
||
def abo_basic_login_group | ||
Group::AboBasicLogin.where(layer_group_id: Group.root.id).first | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Copyright (c) 2024, Schweizer Alpen-Club. This file is part of | ||
# hitobito 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. | ||
|
||
require "spec_helper" | ||
|
||
describe Event::RegisterController do | ||
include ActiveJob::TestHelper | ||
|
||
let(:event) do | ||
events(:top_event).tap do |e| | ||
e.update_column(:external_applications, true) | ||
end | ||
end | ||
let(:group) { event.groups.first } | ||
before do | ||
Group::AboBasicLogin.create!( | ||
parent: groups(:abos), | ||
self_registration_role_type: "Group::AboBasicLogin::BasicLogin" | ||
) | ||
end | ||
|
||
let(:attrs) { | ||
{ | ||
first_name: "Max", | ||
last_name: "Muster", | ||
street: "Musterplatz", | ||
housenumber: "23", | ||
email: "[email protected]", | ||
zip_code: "8000", | ||
town: "Zürich", | ||
country: "CH", | ||
birthday: "01.01.1980", | ||
phone_numbers_attributes: { | ||
"0": { | ||
number: "+41 79 123 45 56", | ||
public: true, | ||
translated_label: "Mobile" | ||
} | ||
} | ||
}.with_indifferent_access | ||
} | ||
|
||
describe "PUT register" do | ||
context "with valid data" do | ||
it "creates person and sends password reset instructions" do | ||
event.update!(required_contact_attrs: []) | ||
|
||
expect(Devise::Mailer).to receive(:reset_password_instructions).and_call_original | ||
|
||
expect do | ||
put :register, params: {group_id: group.id, id: event.id, event_participation_contact_data: attrs} | ||
end.to change { Person.count }.by(1) | ||
.and change { Group::AboBasicLogin::BasicLogin.count }.by(1) | ||
|
||
person = Person.find_by(email: "[email protected]") | ||
|
||
expect(person.roles.size).to eq(1) | ||
expect(person.roles.first.type).to eq(Group::AboBasicLogin::BasicLogin.sti_name) | ||
is_expected.to redirect_to(new_group_event_participation_path(group, event)) | ||
expect(flash[:notice]).to include "Deine persönlichen Daten wurden aufgenommen. Bitte ergänze nun noch die Angaben" | ||
end | ||
end | ||
end | ||
end |