Non far crashare il reset password se SMTP rifiuta il destinatario.

Un account di test su dominio .test faceva 500; ora l'invio fallito viene loggato e l'API resta ok.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-31 12:00:22 +02:00
co-authored by Cursor
parent 645807b853
commit 79850dfc2c
2 changed files with 18 additions and 0 deletions
+11
View File
@@ -120,6 +120,17 @@ RSpec.describe "Account API", type: :request do
expect(user.reload.password_reset_digest).to be_present
end
it "non va in 500 se SMTP rifiuta il destinatario" do
allow_any_instance_of(ActionMailer::MessageDelivery).to receive(:deliver_now)
.and_raise(Net::SMTPFatalError.new("556 5.1.10 invalid destination domain"))
expect {
post "/api/v1/auth/password/forgot", params: { email: user.email }
}.not_to raise_error
expect(response).to have_http_status(:ok)
expect(user.reload.password_reset_digest).to be_present
end
it "returns the same message for unknown emails" do
expect {
post "/api/v1/auth/password/forgot", params: { email: "nobody@example.com" }