mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Remove unused spree checkout and spree cart routes
This commit is contained in:
@@ -202,11 +202,11 @@ class CheckoutController < Spree::CheckoutController
|
||||
def redirect_to_cart_path
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
redirect_to cart_path
|
||||
redirect_to main_app.cart_path
|
||||
end
|
||||
|
||||
format.json do
|
||||
render json: { path: cart_path }, status: :bad_request
|
||||
render json: { path: main_app.cart_path }, status: :bad_request
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ class EnterprisesController < BaseController
|
||||
respond_to :js, only: :permalink_checker
|
||||
|
||||
def shop
|
||||
return redirect_to spree.cart_path unless enough_stock?
|
||||
return redirect_to main_app.cart_path unless enough_stock?
|
||||
set_noindex_meta_tag
|
||||
|
||||
enterprises = current_distributor
|
||||
|
||||
@@ -28,7 +28,7 @@ class Spree::CheckoutController < Spree::StoreController
|
||||
|
||||
def load_order
|
||||
@order = current_order
|
||||
redirect_to spree.cart_path and return unless @order
|
||||
redirect_to main_app.cart_path and return unless @order
|
||||
|
||||
if params[:state]
|
||||
redirect_to checkout_state_path(@order.state) if @order.can_go_to_state?(params[:state])
|
||||
@@ -39,18 +39,18 @@ class Spree::CheckoutController < Spree::StoreController
|
||||
|
||||
def ensure_checkout_allowed
|
||||
unless @order.checkout_allowed?
|
||||
redirect_to spree.cart_path
|
||||
redirect_to main_app.cart_path
|
||||
end
|
||||
end
|
||||
|
||||
def ensure_order_not_completed
|
||||
redirect_to spree.cart_path if @order.completed?
|
||||
redirect_to main_app.cart_path if @order.completed?
|
||||
end
|
||||
|
||||
def ensure_sufficient_stock_lines
|
||||
if @order.insufficient_stock_lines.present?
|
||||
flash[:error] = Spree.t(:inventory_error_flash_for_insufficient_quantity)
|
||||
redirect_to spree.cart_path
|
||||
redirect_to main_app.cart_path
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class Spree::OrdersController < Spree::StoreController
|
||||
@order.empty!
|
||||
end
|
||||
|
||||
redirect_to spree.cart_path
|
||||
redirect_to main_app.cart_path
|
||||
end
|
||||
|
||||
def check_authorization
|
||||
@@ -90,7 +90,7 @@ class Spree::OrdersController < Spree::StoreController
|
||||
elsif @order.complete?
|
||||
redirect_to order_path(@order)
|
||||
else
|
||||
redirect_to cart_path
|
||||
redirect_to main_app.cart_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
%p.alert-box.info
|
||||
= t '.message_html', cart: link_to(t('.cart'), "#{cart_path}#bought-products")
|
||||
= t '.message_html', cart: link_to(t('.cart'), "#{main_app.cart_path}#bought-products")
|
||||
|
||||
@@ -30,6 +30,6 @@
|
||||
%td.text-right {{ Checkout.cartTotal() | localizeCurrency }}
|
||||
|
||||
//= f.submit "Purchase", class: "button", "ofn-focus" => "accordion['payment']"
|
||||
%a.button.secondary{href: cart_url}
|
||||
%a.button.secondary{href: main_app.cart_url}
|
||||
%i.ofn-i_008-caret-left
|
||||
= t :checkout_back_to_cart
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
%h5
|
||||
= t 'cart_headline'
|
||||
.buttons.text-right
|
||||
%a.button.secondary.tiny.add_to_cart{ href: cart_path, type: :submit, "ng-disabled" => "Cart.dirty || Cart.empty()", "ng-class" => "{ dirty: Cart.dirty }" }
|
||||
%a.button.secondary.tiny.add_to_cart{ href: main_app.cart_path, type: :submit, "ng-disabled" => "Cart.dirty || Cart.empty()", "ng-class" => "{ dirty: Cart.dirty }" }
|
||||
= "{{ Cart.dirty ? '#{t(:cart_updating)}' : (Cart.empty() ? '#{t(:cart_empty)}' : '#{t(:cart_edit)}' ) }}"
|
||||
%a.button.primary.tiny{href: checkout_path, "ng-disabled" => "Cart.dirty || Cart.empty()"}
|
||||
%a.button.primary.tiny{href: main_app.checkout_path, "ng-disabled" => "Cart.dirty || Cart.empty()"}
|
||||
= t '.checkout'
|
||||
%table
|
||||
%tr.product-cart{"ng-repeat" => "line_item in Cart.line_items", "id" => "cart-variant-{{ line_item.variant.id }}"}
|
||||
@@ -36,9 +36,9 @@
|
||||
%strong {{ Cart.total() | localizeCurrency }}
|
||||
|
||||
.buttons.text-right
|
||||
%a.button.secondary.tiny.add_to_cart{ href: cart_path, type: :submit, "ng-disabled" => "Cart.dirty || Cart.empty()", "ng-class" => "{ dirty: Cart.dirty }" }
|
||||
%a.button.secondary.tiny.add_to_cart{ href: main_app.cart_path, type: :submit, "ng-disabled" => "Cart.dirty || Cart.empty()", "ng-class" => "{ dirty: Cart.dirty }" }
|
||||
= "{{ Cart.dirty ? '#{t(:cart_updating)}' : (Cart.empty() ? '#{t(:cart_empty)}' : '#{t(:cart_edit)}' ) }}"
|
||||
%a.button.primary.tiny{href: checkout_path, "ng-disabled" => "Cart.dirty || Cart.empty()"}
|
||||
%a.button.primary.tiny{href: main_app.checkout_path, "ng-disabled" => "Cart.dirty || Cart.empty()"}
|
||||
= t '.checkout'
|
||||
- if order_changes_allowed?
|
||||
%h5{"ng-if" => "Cart.line_items_finalised.length", style: 'margin-top: 1em'}
|
||||
|
||||
@@ -48,6 +48,6 @@
|
||||
= t :search_no_results_html, query: "<strong>{{query}}</strong>".html_safe
|
||||
.row
|
||||
.small-12.columns
|
||||
%form{action: cart_path}
|
||||
%form{action: main_app.cart_path}
|
||||
%i.ofn-i_011-spinner.cart-spinner{"ng-show" => "Cart.dirty"}
|
||||
%input.small.button.primary.right.add_to_cart{type: :submit, value: "{{ Cart.dirty ? '#{t(:products_updating_cart)}' : (Cart.empty() ? '#{t(:products_cart_empty)}' : '#{t(:products_edit_cart)}' ) }}", "ng-disabled" => "Cart.dirty || Cart.empty()", "ng-class" => "{ dirty: Cart.dirty }" }
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
- else
|
||||
%div{"data-hook" => "outside_cart_form"}
|
||||
= form_for @order, :url => update_cart_path, :html => {:id => 'update-cart'} do |order_form|
|
||||
= form_for @order, :url => main_app.update_cart_path, :html => {:id => 'update-cart'} do |order_form|
|
||||
%div{"data-hook" => "inside_cart_form"}
|
||||
%div{"data-hook" => "cart_items"}
|
||||
.row
|
||||
|
||||
@@ -7,4 +7,4 @@
|
||||
%td
|
||||
%td#empty-cart.text-center
|
||||
%span#clear_cart_link{"data-hook" => ""}
|
||||
= link_to t(:orders_form_empty_cart), empty_cart_path, method: :put, :class => 'not-bold small'
|
||||
= link_to t(:orders_form_empty_cart), main_app.empty_cart_path, method: :put, :class => 'not-bold small'
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
.columns.small-12.medium-3
|
||||
- if current_order.andand.distributor == @order.distributor
|
||||
- if current_order.line_items.present?
|
||||
= link_to spree.cart_path, :class => "button expand" do
|
||||
= link_to main_app.cart_path, :class => "button expand" do
|
||||
%i.ofn-i_008-caret-left
|
||||
= t(:order_back_to_cart)
|
||||
- else
|
||||
|
||||
@@ -27,6 +27,7 @@ Openfoodnetwork::Application.routes.draw do
|
||||
get "/cart", :to => "spree/orders#edit", :as => :cart
|
||||
put "/cart", :to => "spree/orders#update", :as => :update_cart
|
||||
put "/cart/empty", :to => 'spree/orders#empty', :as => :empty_cart
|
||||
match '/orders/:id/token/:token' => 'spree/orders#show', :via => :get, :as => :token_order
|
||||
|
||||
resource :cart, controller: "cart" do
|
||||
post :populate
|
||||
|
||||
@@ -94,8 +94,6 @@ Spree::Core::Engine.routes.prepend do
|
||||
resources :states, :only => :index
|
||||
resources :countries, :only => :index
|
||||
|
||||
match '/orders/:id/token/:token' => 'orders#show', :via => :get, :as => :token_order
|
||||
|
||||
# route globbing for pretty nested taxon and product paths
|
||||
match '/t/*id', :to => 'taxons#show', :as => :nested_taxons
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ describe CheckoutController, type: :controller do
|
||||
allow(order).to receive_message_chain(:insufficient_stock_lines, :empty?).and_return false
|
||||
|
||||
get :edit
|
||||
expect(response).to redirect_to spree.cart_path
|
||||
expect(response).to redirect_to cart_path
|
||||
end
|
||||
|
||||
it "redirects when some items are not available" do
|
||||
@@ -59,7 +59,7 @@ describe CheckoutController, type: :controller do
|
||||
expect(order_cycle_distributed_variants).to receive(:distributes_order_variants?).with(order).and_return(false)
|
||||
|
||||
get :edit
|
||||
expect(response).to redirect_to spree.cart_path
|
||||
expect(response).to redirect_to cart_path
|
||||
end
|
||||
|
||||
it "does not redirect when items are available and in stock" do
|
||||
|
||||
@@ -108,7 +108,7 @@ describe EnterprisesController, type: :controller do
|
||||
it "redirects to the cart" do
|
||||
spree_get :shop, id: current_distributor
|
||||
|
||||
expect(response).to redirect_to spree.cart_path
|
||||
expect(response).to redirect_to cart_path
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ feature 'Multilingual', js: true do
|
||||
end
|
||||
|
||||
scenario "in the cart page" do
|
||||
visit spree.cart_path(locale: 'es')
|
||||
visit main_app.cart_path(locale: 'es')
|
||||
|
||||
expect_menu_and_cookie_in_es
|
||||
expect(page).to have_content 'Precio'
|
||||
|
||||
@@ -23,7 +23,7 @@ feature "full-page cart", js: true do
|
||||
describe "product description" do
|
||||
it "does not link to the product page" do
|
||||
add_product_to_cart order, product_with_fee, quantity: 2
|
||||
visit spree.cart_path
|
||||
visit main_app.cart_path
|
||||
expect(page).to have_no_selector '.item-thumb-image a'
|
||||
end
|
||||
end
|
||||
@@ -34,7 +34,7 @@ feature "full-page cart", js: true do
|
||||
before do
|
||||
add_enterprise_fee percentage_fee
|
||||
add_product_to_cart order, product_with_fee, quantity: 8
|
||||
visit spree.cart_path
|
||||
visit main_app.cart_path
|
||||
end
|
||||
|
||||
it "rounds fee calculations correctly" do
|
||||
@@ -57,7 +57,7 @@ feature "full-page cart", js: true do
|
||||
before do
|
||||
add_enterprise_fee handling_fee
|
||||
add_product_to_cart order, product_with_fee, quantity: 3
|
||||
visit spree.cart_path
|
||||
visit main_app.cart_path
|
||||
end
|
||||
|
||||
it "shows admin and handlings row" do
|
||||
@@ -73,7 +73,7 @@ feature "full-page cart", js: true do
|
||||
context "when there are no admin and handling fees" do
|
||||
before do
|
||||
add_product_to_cart order, product_with_fee, quantity: 2
|
||||
visit spree.cart_path
|
||||
visit main_app.cart_path
|
||||
end
|
||||
|
||||
it "hides admin and handlings row" do
|
||||
@@ -102,7 +102,7 @@ feature "full-page cart", js: true do
|
||||
cart_service.populate(variants: { product_with_fee.variants.first.id => 3, product_with_tax.variants.first.id => 3 })
|
||||
order.update_distribution_charge!
|
||||
|
||||
visit spree.cart_path
|
||||
visit main_app.cart_path
|
||||
end
|
||||
|
||||
it "shows the correct weight calculations" do
|
||||
@@ -118,7 +118,7 @@ feature "full-page cart", js: true do
|
||||
before do
|
||||
add_enterprise_fee enterprise_fee
|
||||
add_product_to_cart order, product_with_tax
|
||||
visit spree.cart_path
|
||||
visit main_app.cart_path
|
||||
end
|
||||
|
||||
it "shows the total tax for the order, including product tax and tax on fees" do
|
||||
@@ -137,7 +137,7 @@ feature "full-page cart", js: true do
|
||||
it "prevents me from entering an invalid value" do
|
||||
# Given we have 2 on hand, and we've loaded the page after that fact
|
||||
variant.update_attributes!(on_hand: 2, on_demand: false)
|
||||
visit spree.cart_path
|
||||
visit main_app.cart_path
|
||||
|
||||
accept_alert 'Insufficient stock available, only 2 remaining' do
|
||||
fill_in "order_line_items_attributes_0_quantity", with: '4'
|
||||
@@ -149,7 +149,7 @@ feature "full-page cart", js: true do
|
||||
# Given we load the page with 3 on hand, then the number available drops to 2
|
||||
variant.update_attributes! on_demand: false
|
||||
variant.update_attributes! on_hand: 3
|
||||
visit spree.cart_path
|
||||
visit main_app.cart_path
|
||||
variant.update_attributes! on_hand: 2
|
||||
|
||||
accept_alert do
|
||||
@@ -175,7 +175,7 @@ feature "full-page cart", js: true do
|
||||
order.distributor.save
|
||||
add_product_to_cart order, product_with_tax
|
||||
quick_login_as user
|
||||
visit spree.cart_path
|
||||
visit main_app.cart_path
|
||||
end
|
||||
|
||||
it "shows already ordered line items" do
|
||||
@@ -199,7 +199,7 @@ feature "full-page cart", js: true do
|
||||
expect(page).to have_no_content item1.variant.name
|
||||
expect(page).to have_content item2.variant.name
|
||||
|
||||
visit spree.cart_path
|
||||
visit main_app.cart_path
|
||||
|
||||
find("td.toggle-bought").click
|
||||
expect(page).to have_no_content item1.variant.name
|
||||
|
||||
Reference in New Issue
Block a user