diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index e6c82e01ec6..1415f78f573 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -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 diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb index 99954375195..f521898bf07 100644 --- a/spec/controllers/notifications_controller_spec.rb +++ b/spec/controllers/notifications_controller_spec.rb @@ -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