Raise 404 from Admin::UsersController#show if no user found

[Fixes #353]
This commit is contained in:
Alexander 2013-03-05 14:02:23 -08:00
parent 6edabdfec1
commit c4f1cb0d7b
2 changed files with 15 additions and 5 deletions

View File

@ -16,6 +16,7 @@ class Admin::UsersController < Admin::AdminController
def show def show
@user = User.where(username_lower: params[:id]).first @user = User.where(username_lower: params[:id]).first
raise Discourse::NotFound.new unless @user
render_serialized(@user, AdminDetailedUserSerializer, root: false) render_serialized(@user, AdminDetailedUserSerializer, root: false)
end end

View File

@ -2,7 +2,7 @@ require 'spec_helper'
describe Admin::UsersController do describe Admin::UsersController do
it "is a subclass of AdminController" do it 'is a subclass of AdminController' do
(Admin::UsersController < Admin::AdminController).should be_true (Admin::UsersController < Admin::AdminController).should be_true
end end
@ -23,13 +23,22 @@ describe Admin::UsersController do
end end
end end
context '.show' do describe '.show' do
context 'an existing user' do
it 'returns success' do it 'returns success' do
xhr :get, :show, id: @user.username xhr :get, :show, id: @user.username
response.should be_success response.should be_success
end end
end end
context 'an existing user' do
it 'returns success' do
xhr :get, :show, id: 'foobar'
response.should_not be_success
end
end
end
context '.approve_bulk' do context '.approve_bulk' do
let(:evil_trout) { Fabricate(:evil_trout) } let(:evil_trout) { Fabricate(:evil_trout) }