mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 12:08:01 +00:00
fix: ActiveRecord::RecordNotFound Couldn't find Channel::WebWidget (#6523)
* fix: resucue ActiveRecord::RecordNotFound for webwidget controller * chore: add rails.log
This commit is contained in:
@@ -18,6 +18,9 @@ class WidgetsController < ActionController::Base
|
||||
|
||||
def set_web_widget
|
||||
@web_widget = ::Channel::WebWidget.find_by!(website_token: permitted_params[:website_token])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
Rails.logger.error('web widget does not exist')
|
||||
render json: { error: 'web widget does not exist' }, status: :not_found
|
||||
end
|
||||
|
||||
def set_token
|
||||
|
||||
@@ -33,5 +33,13 @@ describe '/widget', type: :request do
|
||||
expect(response).to have_http_status(:unauthorized)
|
||||
expect(response.body).to include('Account is suspended')
|
||||
end
|
||||
|
||||
it 'returns 404 if the webwidget is deleted' do
|
||||
web_widget.delete
|
||||
|
||||
get widget_url(website_token: web_widget.website_token)
|
||||
expect(response).to have_http_status(:not_found)
|
||||
expect(response.body).to include('web widget does not exist')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user