mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Handle both types of redirection
One is based on the order step itself, the other is based on the current step passed through the params
This commit is contained in:
@@ -17,7 +17,7 @@ class SplitCheckoutController < ::BaseController
|
||||
helper OrderHelper
|
||||
|
||||
def edit
|
||||
redirect_to_step unless params[:step]
|
||||
redirect_to_step_based_on_order unless params[:step]
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -116,7 +116,7 @@ class SplitCheckoutController < ::BaseController
|
||||
@order_params ||= Checkout::Params.new(@order, params, spree_current_user).call
|
||||
end
|
||||
|
||||
def redirect_to_step
|
||||
def redirect_to_step_based_on_order
|
||||
case @order.state
|
||||
when "cart", "address", "delivery"
|
||||
redirect_to checkout_step_path(:details)
|
||||
@@ -128,4 +128,14 @@ class SplitCheckoutController < ::BaseController
|
||||
redirect_to order_path(@order)
|
||||
end
|
||||
end
|
||||
|
||||
def redirect_to_step
|
||||
case params[:step]
|
||||
when "details"
|
||||
return redirect_to checkout_step_path(:payment)
|
||||
when "payment"
|
||||
return redirect_to checkout_step_path(:summary)
|
||||
end
|
||||
redirect_to_step_based_on_order
|
||||
end
|
||||
end
|
||||
|
||||
@@ -425,6 +425,26 @@ describe "As a consumer, I want to checkout my order", js: true do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "handle the navigation when the order is ready for confirmation" do
|
||||
it "redirect to summary step" do
|
||||
visit "/checkout"
|
||||
|
||||
expect(page).to have_current_path checkout_step_path(:summary)
|
||||
end
|
||||
|
||||
it "handle the navigation between each step by clicking on tab or button to submit the form" do
|
||||
visit checkout_step_path(:summary)
|
||||
|
||||
click_on "Your details"
|
||||
|
||||
expect(page).to have_current_path checkout_step_path(:details)
|
||||
|
||||
click_on "Next - Payment method"
|
||||
|
||||
expect(page).to have_current_path checkout_step_path(:payment)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user