Display error messages to user for convencience

It will also help us to debug the application if the error is not
obvious.
This commit is contained in:
Maikel Linke
2023-01-25 13:56:00 +11:00
parent 0782447863
commit ab7e1ac39f
3 changed files with 6 additions and 1 deletions

View File

@@ -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")).

View File

@@ -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"

View File

@@ -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?"