Browse Source

Maintenance: Invalid email error message is not expressive.

Thorsten Eckel 5 years ago
parent
commit
fbbc50f24a

+ 1 - 1
app/controllers/tickets_controller.rb

@@ -100,7 +100,7 @@ class TicketsController < ApplicationController
       email_address = $1
       email_address_validation = EmailAddressValidation.new(email_address)
       if !email_address_validation.valid_format?
-        render json: { error: 'Invalid email of customer' }, status: :unprocessable_entity
+        render json: { error: "Invalid email '#{email_address}' of customer" }, status: :unprocessable_entity
         return
       end
       local_customer = User.find_by(email: email_address.downcase)

+ 1 - 1
app/models/email_address.rb

@@ -50,7 +50,7 @@ check and if channel not exists reset configured channels for email addresses
     self.email = email.downcase.strip
     email_address_validation = EmailAddressValidation.new(email)
     if !email_address_validation.valid_format?
-      raise Exceptions::UnprocessableEntity, 'Invalid email'
+      raise Exceptions::UnprocessableEntity, "Invalid email '#{email}'"
     end
 
     true

+ 1 - 1
app/models/user.rb

@@ -962,7 +962,7 @@ try to find correct name
 
     email_address_validation = EmailAddressValidation.new(email)
     if !email_address_validation.valid_format?
-      raise Exceptions::UnprocessableEntity, 'Invalid email'
+      raise Exceptions::UnprocessableEntity, "Invalid email '#{email}'"
     end
 
     true

+ 1 - 1
lib/email_helper/probe.rb

@@ -56,7 +56,7 @@ returns on fail
         return {
           result:   'invalid',
           messages: {
-            email: 'Invalid email.'
+            email: "Invalid email '#{params[:email]}'."
           },
         }
       end

+ 1 - 1
spec/requests/user_spec.rb

@@ -309,7 +309,7 @@ RSpec.describe 'User', type: :request, searchindex: true do
       post '/api/v1/users', params: params, as: :json
       expect(response).to have_http_status(:unprocessable_entity)
       expect(json_response).to be_truthy
-      expect(json_response['error']).to eq('Invalid email')
+      expect(json_response['error']).to eq("Invalid email 'some_what'")
 
       # with valid attributes
       params = { firstname: 'newfirstname123', note: 'some note' }