Skip to content

Commit

Permalink
Create basic abo login role on external event registration
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWalkingLeek committed Dec 17, 2024
1 parent 44b9e5d commit 21a3ab2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/controllers/sac_cas/event/register_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions spec/controllers/event/register_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
{
Expand Down Expand Up @@ -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: "[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
Expand Down

0 comments on commit 21a3ab2

Please sign in to comment.