Skip to content

Commit

Permalink
Redirect to group person path if not able to show person (#1370)
Browse files Browse the repository at this point in the history
* Redirect to group person path if not able to show person
* Adjust specs

---------

Co-authored-by: Robin <[email protected]>
  • Loading branch information
njaeggi and openscript authored Dec 12, 2024
1 parent 3485634 commit 926eb84
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ def success_message

# NOTE: format: :html is required otherwise it is redirect as turbo_stream
def redirect_target
person_path(person, format: :html)
# if the current_user does not have the ability to show the person in other groups the person has (or will have) roles
# in, we redirect to the member list and display the flash message there
if can?(:show, person)
person_path(person, format: :html)
else
group_people_path(group, format: :html)
end
end

def person
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def expect_terminated_page
end
.to change(Role, :count).by(-2)
.and change { role.termination_reason_id }.from(nil).to(termination_reason_id)
expect(response).to redirect_to person_path(person, format: :html)
expect(response).to redirect_to group_people_path(groups(:bluemlisalp), format: :html)
expect(flash[:notice]).to eq "Deine SAC-Mitgliedschaft wurde gekündet."
end
end
Expand Down

0 comments on commit 926eb84

Please sign in to comment.