forked from e621ng/e621ng
[Users] Fix exception on users?name=non_existant_name
Just redirect to the show page unconditionally, it handles it already
This commit is contained in:
parent
e3575a6efe
commit
7816c8562e
@ -19,12 +19,7 @@ class UsersController < ApplicationController
|
||||
|
||||
def index
|
||||
if params[:name].present?
|
||||
@user = User.find_by_name(params[:name])
|
||||
if @user.nil?
|
||||
raise "No user found with name: #{params[:name]}"
|
||||
else
|
||||
redirect_to user_path(@user)
|
||||
end
|
||||
redirect_to user_path(id: params[:name])
|
||||
else
|
||||
@users = User.search(search_params).includes(:user_status).paginate(params[:page], limit: params[:limit], search_count: params[:search])
|
||||
respond_with(@users) do |format|
|
||||
|
@ -12,14 +12,9 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "list all users for /users?name=<name>" do
|
||||
get users_path, params: { name: @user.name }
|
||||
assert_redirected_to(@user)
|
||||
end
|
||||
|
||||
should "raise error for /users?name=<nonexistent>" do
|
||||
get users_path, params: { name: "nobody" }
|
||||
assert_response :error
|
||||
should "redirect for /users?name=<name>" do
|
||||
get users_path, params: { name: "some_username" }
|
||||
assert_redirected_to(user_path(id: "some_username"))
|
||||
end
|
||||
|
||||
should "list all users (with search)" do
|
||||
|
Loading…
Reference in New Issue
Block a user