FIX: Incorrect error raised.

This commit is contained in:
Guo Xiang Tan 2017-04-25 09:56:26 +08:00
parent 644c15926a
commit 6f7c6b0fd0
2 changed files with 5 additions and 3 deletions

View File

@ -8,7 +8,7 @@ class NotificationsController < ApplicationController
user =
if params[:username] && !params[:recent]
user_record = User.find_by(username: params[:username].to_s)
raise Discourse::InvalidParameters.new(:username) if !user_record
raise Discourse::NotFound if !user_record
user_record
else
current_user

View File

@ -36,8 +36,10 @@ describe NotificationsController do
context 'when username params is not valid' do
it 'should raise the right error' do
expect { xhr :get, :index, username: 'somedude' }
.to raise_error(Discourse::InvalidParameters)
xhr :get, :index, username: 'somedude'
expect(response).to_not be_success
expect(response.status).to eq(404)
end
end
end