diff --git a/app/controllers/checkout_controller.rb b/app/controllers/checkout_controller.rb index dcab812254..1ef23d92a9 100644 --- a/app/controllers/checkout_controller.rb +++ b/app/controllers/checkout_controller.rb @@ -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 diff --git a/app/controllers/enterprises_controller.rb b/app/controllers/enterprises_controller.rb index e33a10a296..f99f068737 100644 --- a/app/controllers/enterprises_controller.rb +++ b/app/controllers/enterprises_controller.rb @@ -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 diff --git a/app/controllers/spree/checkout_controller.rb b/app/controllers/spree/checkout_controller.rb index 3a07a62ef5..1d7e11c587 100644 --- a/app/controllers/spree/checkout_controller.rb +++ b/app/controllers/spree/checkout_controller.rb @@ -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 diff --git a/app/controllers/spree/orders_controller.rb b/app/controllers/spree/orders_controller.rb index c9fe8ed098..cdf236ce94 100644 --- a/app/controllers/spree/orders_controller.rb +++ b/app/controllers/spree/orders_controller.rb @@ -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 diff --git a/app/views/checkout/_already_ordered.html.haml b/app/views/checkout/_already_ordered.html.haml index 01c4265252..3e43591362 100644 --- a/app/views/checkout/_already_ordered.html.haml +++ b/app/views/checkout/_already_ordered.html.haml @@ -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") diff --git a/app/views/checkout/_summary.html.haml b/app/views/checkout/_summary.html.haml index a6bb5ca651..0ca86fcb2e 100644 --- a/app/views/checkout/_summary.html.haml +++ b/app/views/checkout/_summary.html.haml @@ -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 diff --git a/app/views/shared/menu/_joyride.html.haml b/app/views/shared/menu/_joyride.html.haml index 7c819191e3..6d732e0294 100644 --- a/app/views/shared/menu/_joyride.html.haml +++ b/app/views/shared/menu/_joyride.html.haml @@ -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'} diff --git a/app/views/shop/products/_form.html.haml b/app/views/shop/products/_form.html.haml index 98fb49501d..3a9738a532 100644 --- a/app/views/shop/products/_form.html.haml +++ b/app/views/shop/products/_form.html.haml @@ -48,6 +48,6 @@ = t :search_no_results_html, query: "{{query}}".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 }" } diff --git a/app/views/spree/orders/edit.html.haml b/app/views/spree/orders/edit.html.haml index a5afad1178..31574b37d3 100644 --- a/app/views/spree/orders/edit.html.haml +++ b/app/views/spree/orders/edit.html.haml @@ -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 diff --git a/app/views/spree/orders/form/_cart_actions_row.html.haml b/app/views/spree/orders/form/_cart_actions_row.html.haml index 5790f7f9e1..ec3ce122ea 100644 --- a/app/views/spree/orders/form/_cart_actions_row.html.haml +++ b/app/views/spree/orders/form/_cart_actions_row.html.haml @@ -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' diff --git a/app/views/spree/orders/form/_update_buttons.html.haml b/app/views/spree/orders/form/_update_buttons.html.haml index 7a89ab25b4..a054165546 100644 --- a/app/views/spree/orders/form/_update_buttons.html.haml +++ b/app/views/spree/orders/form/_update_buttons.html.haml @@ -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 diff --git a/config/routes.rb b/config/routes.rb index f264d87144..0429de5dfe 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/config/routes/spree.rb b/config/routes/spree.rb index b2ae4f4ef6..2d524791f4 100644 --- a/config/routes/spree.rb +++ b/config/routes/spree.rb @@ -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 diff --git a/spec/controllers/checkout_controller_spec.rb b/spec/controllers/checkout_controller_spec.rb index e7bd7cee2b..ac7f180e2d 100644 --- a/spec/controllers/checkout_controller_spec.rb +++ b/spec/controllers/checkout_controller_spec.rb @@ -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 diff --git a/spec/controllers/enterprises_controller_spec.rb b/spec/controllers/enterprises_controller_spec.rb index 16db10ebfb..084beec9bf 100644 --- a/spec/controllers/enterprises_controller_spec.rb +++ b/spec/controllers/enterprises_controller_spec.rb @@ -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 diff --git a/spec/features/consumer/multilingual_spec.rb b/spec/features/consumer/multilingual_spec.rb index 99ba5a3202..4bf209361c 100644 --- a/spec/features/consumer/multilingual_spec.rb +++ b/spec/features/consumer/multilingual_spec.rb @@ -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' diff --git a/spec/features/consumer/shopping/cart_spec.rb b/spec/features/consumer/shopping/cart_spec.rb index d054bf3d1b..6e1493be14 100644 --- a/spec/features/consumer/shopping/cart_spec.rb +++ b/spec/features/consumer/shopping/cart_spec.rb @@ -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