Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/1453/wizard redirects without primary group #1456

Merged
merged 2 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ def redirect_to_login

def redirect_to_memberships_tab
flash[:notice] = t("groups.self_registration.create.existing_membership_notice")
redirect_to history_group_person_path(group_id: current_user.primary_group_id, id: current_user.id)
redirect_to history_group_person_path(group_id: current_user.primary_group_id || Group.root.id, id: current_user.id)
end

def redirect_to_person_show
flash[:notice] = t("groups.self_registration.create.existing_family_notice")
redirect_to history_group_person_path(group_id: current_user.primary_group_id, id: current_user.id)
redirect_to history_group_person_path(group_id: current_user.primary_group_id || Group.root.id, id: current_user.id)
end

def redirect_to_group_if_necessary
Expand All @@ -70,7 +70,7 @@ def redirect_to_group_if_necessary

def redirect_target
if current_user.present?
history_group_person_path(group_id: current_user.reload.primary_group_id, id: current_user.id)
history_group_person_path(group_id: current_user.reload.primary_group_id || Group.root.id, id: current_user.id)
else
new_person_session_path
end
Expand Down
12 changes: 12 additions & 0 deletions spec/controllers/groups/self_registration_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,17 @@ def wizard_params(step: 0, **attrs)
expect(flash[:notice]).to eq "Du ist einer Familie zugeordnet. Kontaktiere bitte die SAC-Geschäftsstelle."
end
end

context "without primary group id" do
let(:person) { Fabricate(:person) }

it "redirects to memberships tab layered under root group with a flash message" do
allow_any_instance_of(Wizards::Signup::SektionWizard).to receive(:member_or_applied?).and_return(true)
get :show, params: wizard_params

expect(response).to redirect_to(history_group_person_path(group_id: Group.root.id, id: person.id))
expect(flash[:notice]).to eq "Du besitzt bereits eine SAC-Mitgliedschaft. Wenn du diese anpassen möchtest, kontaktiere bitte die SAC-Geschäftsstelle."
end
end
end
end
Loading