From ab7e1ac39fa0f369b418226847aeb7c2b39e2c8c Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 25 Jan 2023 13:56:00 +1100 Subject: [PATCH] Display error messages to user for convencience It will also help us to debug the application if the error is not obvious. --- app/controllers/split_checkout_controller.rb | 5 ++++- config/locales/en.yml | 1 + spec/system/consumer/split_checkout_spec.rb | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/split_checkout_controller.rb b/app/controllers/split_checkout_controller.rb index ce3bb35ca4..28cc0220b2 100644 --- a/app/controllers/split_checkout_controller.rb +++ b/app/controllers/split_checkout_controller.rb @@ -36,7 +36,10 @@ class SplitCheckoutController < ::BaseController advance_order_state redirect_to_step else - flash.now[:error] ||= I18n.t('split_checkout.errors.global') + flash.now[:error] ||= I18n.t( + 'split_checkout.errors.saving_failed', + messages: @order.errors.full_messages.to_sentence + ) render status: :unprocessable_entity, operations: cable_car. replace("#checkout", partial("split_checkout/checkout")). diff --git a/config/locales/en.yml b/config/locales/en.yml index 1e1f4537ff..e2c360b9af 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1997,6 +1997,7 @@ en: cancel: Back to Payment method errors: global: "Saving failed, please update the highlighted fields." + saving_failed: "Saving failed, please update the highlighted fields. %{messages}" terms_not_accepted: Please accept Terms and Conditions required: Field cannot be blank invalid_number: "Please enter a valid phone number" diff --git a/spec/system/consumer/split_checkout_spec.rb b/spec/system/consumer/split_checkout_spec.rb index 9b53969569..f77a6d6cdc 100644 --- a/spec/system/consumer/split_checkout_spec.rb +++ b/spec/system/consumer/split_checkout_spec.rb @@ -294,6 +294,7 @@ describe "As a consumer, I want to checkout my order" do click_button "Next - Payment method" expect(page).to have_content "Saving failed, please update the highlighted fields." + expect(page).to have_content "Ship address address1 can't be blank" expect(page).to have_content "Shipping address same as billing address?" expect(page).to have_content "Save as default shipping address" expect(page).to have_checked_field "Shipping address same as billing address?"