mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-29 21:17:17 +00:00
Add a flash error where no available shipping methods to the customer
+ update specs as well
This commit is contained in:
@@ -23,6 +23,8 @@ class SplitCheckoutController < ::BaseController
|
||||
redirect_to_step_based_on_order unless params[:step]
|
||||
check_step if params[:step]
|
||||
recalculate_tax if params[:step] == "summary"
|
||||
|
||||
flash_error_when_no_shipping_method_available if available_shipping_methods.none?
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -47,6 +49,10 @@ class SplitCheckoutController < ::BaseController
|
||||
|
||||
private
|
||||
|
||||
def flash_error_when_no_shipping_method_available
|
||||
flash[:error] = I18n.t('split_checkout.errors.no_shipping_methods_available')
|
||||
end
|
||||
|
||||
def clear_invalid_payments
|
||||
@order.payments.with_state(:invalid).delete_all
|
||||
end
|
||||
|
||||
@@ -1903,6 +1903,7 @@ en:
|
||||
invalid_email: "Please enter a valid email address"
|
||||
select_a_shipping_method: Select a shipping method
|
||||
select_a_payment_method: Select a payment method
|
||||
no_shipping_methods_available: Checkout is not possible due to absence of shipping options. Please contact the shop owner.
|
||||
order_paid: PAID
|
||||
order_not_paid: NOT PAID
|
||||
order_total: Total order
|
||||
|
||||
@@ -142,6 +142,23 @@ describe "As a consumer, I want to checkout my order", js: true do
|
||||
expect_to_be_on_first_step
|
||||
end
|
||||
|
||||
context "when no shipping methods are available" do
|
||||
before do
|
||||
shipping_methods.each { |sm| sm.update(tag_list: "hidden") }
|
||||
end
|
||||
|
||||
it "should display an error message" do
|
||||
create(:filter_shipping_methods_tag_rule,
|
||||
enterprise: distributor,
|
||||
is_default: true,
|
||||
preferred_shipping_method_tags: "hidden",
|
||||
preferred_matched_shipping_methods_visibility: 'hidden')
|
||||
|
||||
visit checkout_path
|
||||
expect(page).to have_content "Checkout is not possible due to absence of shipping options. Please contact the shop owner."
|
||||
end
|
||||
end
|
||||
|
||||
it "should display error when fields are empty" do
|
||||
click_on "Checkout as guest"
|
||||
click_button "Next - Payment method"
|
||||
|
||||
Reference in New Issue
Block a user