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

AO3-6791 Raise 404 when editing a pseud for a user that doesn't exist #5047

Merged
merged 6 commits into from
Feb 23, 2025
Merged
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
2 changes: 2 additions & 0 deletions app/controllers/pseuds_controller.rb
Original file line number Diff line number Diff line change
@@ -74,6 +74,8 @@ def new

# GET /pseuds/1/edit
def edit
raise ActiveRecord::RecordNotFound, "Couldn't find user '#{params[:user_id]}'" unless @user

@pseud = @user.pseuds.find_by!(name: params[:id])
authorize @pseud if logged_in_as_admin?
end
5 changes: 5 additions & 0 deletions spec/controllers/pseuds_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -81,6 +81,11 @@
expect { get :edit, params: { user_id: user, id: "fake_pseud" } }
.to raise_error(ActiveRecord::RecordNotFound)
end

it "returns NotFound error when user doesn't exist" do
expect { get :edit, params: { user_id: "fake_user", id: pseud } }
.to raise_error(ActiveRecord::RecordNotFound)
end
end
end
end