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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions app/controllers/pseuds_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions spec/controllers/pseuds_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@
subject.call
expect(response).to render_template(:edit)
end

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