diff --git a/app/controllers/sac_cas/event/register_controller.rb b/app/controllers/sac_cas/event/register_controller.rb index 81d9597d3..fe9005f4a 100644 --- a/app/controllers/sac_cas/event/register_controller.rb +++ b/app/controllers/sac_cas/event/register_controller.rb @@ -9,6 +9,11 @@ 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 diff --git a/spec/controllers/event/register_controller_spec.rb b/spec/controllers/event/register_controller_spec.rb index 220bf87bd..db8a8f58a 100644 --- a/spec/controllers/event/register_controller_spec.rb +++ b/spec/controllers/event/register_controller_spec.rb @@ -14,6 +14,12 @@ 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) { { @@ -46,7 +52,12 @@ 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: "max.muster@example.com") + 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