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-6790 Raise 404 when attempting to edit pseud that doesn't exist #5046

Merged
merged 3 commits into from
Feb 18, 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
2 changes: 1 addition & 1 deletion app/controllers/pseuds_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def new

# GET /pseuds/1/edit
def edit
@pseud = @user.pseuds.find_by(name: params[:id])
@pseud = @user.pseuds.find_by!(name: params[:id])
authorize @pseud if logged_in_as_admin?
end

Expand Down
14 changes: 14 additions & 0 deletions spec/controllers/pseuds_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,23 @@
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: user, id: "fake_pseud" } }
.to raise_error(ActiveRecord::RecordNotFound)
end
end
end
end

context "when logged in as user" do
before { fake_login_known_user(user) }

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

describe "update" do
Expand Down
Loading