mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Add flash after an order is cancelled
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user