fix(EmailCheckerController): with partial email, should not raise error

This commit is contained in:
mfo 2024-06-17 13:25:28 +02:00
parent 06b8194359
commit d1e983ed97
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC
2 changed files with 10 additions and 0 deletions

View file

@ -627,6 +627,8 @@ class EmailChecker
return { success: true } if similar_domains.empty?
{ success: true, email_suggestions: email_suggestions(parsed_email:, similar_domains:) }
rescue Mail::Field::IncompleteParseError
return { success: false }
end
private

View file

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