Merge pull request #10967 from demarches-simplifiees/fix-10966

Fix 500 when email is malformed
This commit is contained in:
Mathieu Magnin 2024-10-23 07:23:07 +00:00 committed by GitHub
commit ba54890632
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View file

@ -2,6 +2,6 @@
class EmailCheckerController < ApplicationController
def show
render json: EmailChecker.check(email: params[:email])
render json: EmailChecker.check(email: params.permit(:email)[:email])
end
end

View file

@ -45,5 +45,13 @@ describe EmailCheckerController, type: :controller do
expect(body).to eq({ success: false })
end
end
context 'malformed' do
let(:params) { { email: { some: 'hash' } } }
it do
expect(response).to have_http_status(:success)
expect(body).to eq({ success: false })
end
end
end
end