Skip to content

Commit

Permalink
Fix redirect after admin updates another user's name
Browse files Browse the repository at this point in the history
Trello: https://trello.com/c/DjdHEqxG

This was a mistake in #2497.

When the update completes successfully, the admin should be taken back
to the edit user page for the user in question.

Previously they were redirected to the *non-existent* path for a
non-existent `UsersController#show` action which was somehow (🤷)
being handled by `UsersController#edit` as I intended!
  • Loading branch information
floehopper committed Nov 9, 2023
1 parent de64c49 commit f1b02b1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/users/names_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def edit; end
def update
if @user.update(user_params)
EventLog.record_event(@user, EventLog::ACCOUNT_UPDATED, initiator: current_user, ip_address: user_ip_address)
redirect_to user_path(@user), notice: "Updated user #{@user.email} successfully"
redirect_to edit_user_path(@user), notice: "Updated user #{@user.email} successfully"
else
render :edit
end
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/users/names_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class Users::NamesControllerTest < ActionController::TestCase

put :update, params: { user_id: user, user: { name: "new-user-name" } }

assert_redirected_to user_path(user), notice: "Updated name of user@gov.uk successfully"
assert_redirected_to edit_user_path(user), notice: "Updated name of user@gov.uk successfully"
end

should "update user name if UserPolicy#update? returns true" do
Expand Down

0 comments on commit f1b02b1

Please sign in to comment.