diff --git a/app/controllers/concerns/idv/document_capture_concern.rb b/app/controllers/concerns/idv/document_capture_concern.rb index 790f0c64907..3fd24874cd1 100644 --- a/app/controllers/concerns/idv/document_capture_concern.rb +++ b/app/controllers/concerns/idv/document_capture_concern.rb @@ -24,21 +24,16 @@ def successful_response # copied from Flow::Failure module def failure(message = nil, extra = nil) form_response_params = { success: false } - form_response_params[:errors] = make_error_hash(message) + form_response_params[:errors] = error_hash(message) form_response_params[:extra] = extra unless extra.nil? FormResponse.new(**form_response_params) end - def make_error_hash(message) - Rails.logger.info("make_error_hash: stored_result: #{stored_result.inspect}") - - error_hash = { message: message || I18n.t('doc_auth.errors.general.network_error') } - - if stored_result&.errors&.has_key?(:socure) - error_hash[:socure] = stored_result.errors[:socure] - end - - error_hash + def error_hash(message) + { + message: message || I18n.t('doc_auth.errors.general.network_error'), + socure: stored_result&.errors&.dig(:socure), + } end def extract_pii_from_doc(user, store_in_session: false) diff --git a/app/presenters/socure_error_presenter.rb b/app/presenters/socure_error_presenter.rb index d57dbad1664..454dccf7815 100644 --- a/app/presenters/socure_error_presenter.rb +++ b/app/presenters/socure_error_presenter.rb @@ -151,8 +151,11 @@ def heading_string_for(error_code) def error_string_for(error_code) if error_code == :network - t('doc_auth.errors.general.new_network_error') - elsif remapped_error(error_code) == 'underage' # special handling because it says 'Login.gov' + return t('doc_auth.errors.general.new_network_error') + end + + remapped_error_code = remapped_error(error_code) + if remapped_error_code == 'underage' # special handling because it says 'Login.gov' I18n.t('doc_auth.errors.underage', app_name: APP_NAME) else # i18n-tasks-use t('doc_auth.errors.unreadable_id') @@ -160,7 +163,7 @@ def error_string_for(error_code) # i18n-tasks-use t('doc_auth.errors.expired_id') # i18n-tasks-use t('doc_auth.errors.low_resolution') # i18n-tasks-use t('doc_auth.errors.id_not_found') - I18n.t("doc_auth.errors.#{remapped_error(error_code)}") + I18n.t("doc_auth.errors.#{remapped_error_code}") end end end diff --git a/app/services/doc_auth/socure/responses/docv_result_response.rb b/app/services/doc_auth/socure/responses/docv_result_response.rb index 4a93b9232ce..49876ec7de3 100644 --- a/app/services/doc_auth/socure/responses/docv_result_response.rb +++ b/app/services/doc_auth/socure/responses/docv_result_response.rb @@ -38,7 +38,6 @@ class DocvResultResponse < DocAuth::Response def initialize(http_response:, biometric_comparison_required: false) @http_response = http_response - @biometric_comparison_required = biometric_comparison_required @pii_from_doc = read_pii diff --git a/spec/controllers/idv/link_sent_controller_spec.rb b/spec/controllers/idv/link_sent_controller_spec.rb index fe7f3ede25d..0ffee447dde 100644 --- a/spec/controllers/idv/link_sent_controller_spec.rb +++ b/spec/controllers/idv/link_sent_controller_spec.rb @@ -223,8 +223,10 @@ before do expect(FormResponse).to receive(:new).with( - { success: false, - errors: { message: error_message } }, + { + success: false, + errors: hash_including(message: error_message), + }, ) end