Add flash after an order is cancelled

This commit is contained in:
binarygit
2022-07-06 15:07:07 +05:45
parent 75b71738df
commit 3c741f0686
2 changed files with 10 additions and 3 deletions

View File

@@ -4,6 +4,8 @@ module Spree
class OrdersController < ::BaseController
include OrderCyclesHelper
include Rails.application.routes.url_helpers
include CablecarResponses
layout 'darkswarm'
@@ -99,7 +101,8 @@ module Spree
else
flash[:error] = I18n.t(:orders_could_not_cancel)
end
redirect_to request.referer || main_app.order_path(@order)
render status: :found,
operations: cable_car.redirect_to(url: request.referer || main_app.order_path(@order))
end
private

View File

@@ -457,7 +457,9 @@ describe Spree::OrdersController, type: :controller do
context "when the order is not yet complete" do
it "responds with forbidden" do
spree_put :cancel, params
expect(response.status).to redirect_to order_path(order)
expect(response).to have_http_status(:found)
expect(response.body).to match(order_path(order)).and match("redirect")
expect(flash[:error]).to eq I18n.t(:orders_could_not_cancel)
end
end
@@ -474,7 +476,9 @@ describe Spree::OrdersController, type: :controller do
it "responds with success" do
spree_put :cancel, params
expect(response.status).to redirect_to order_path(order)
expect(response).to have_http_status(:found)
expect(response.body).to match(order_path(order)).and match("redirect")
expect(flash[:success]).to eq I18n.t(:orders_your_order_has_been_cancelled)
end
end