mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Redirect /products to enterprise path, since this page did not have correct product filtering
This commit is contained in:
@@ -29,7 +29,7 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
|
||||
def require_distributor_chosen
|
||||
unless current_order(false).andand.distributor
|
||||
unless current_distributor
|
||||
redirect_to spree.root_path
|
||||
false
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class BaseController < ApplicationController
|
||||
include Spree::Core::ControllerHelpers
|
||||
include Spree::Core::ControllerHelpers::RespondWith
|
||||
include EnterprisesHelper
|
||||
include OrderCyclesHelper
|
||||
|
||||
helper 'spree/base'
|
||||
|
||||
@@ -3,15 +3,11 @@ require 'open_food_network/split_products_by_distribution'
|
||||
Spree::ProductsController.class_eval do
|
||||
include EnterprisesHelper
|
||||
include OrderCyclesHelper
|
||||
include OpenFoodNetwork::SplitProductsByDistribution
|
||||
|
||||
before_filter :require_distributor_chosen, only: :index
|
||||
|
||||
respond_override :index => { :html => { :success => lambda {
|
||||
if current_order_cycle
|
||||
order_cycle_products = current_order_cycle.products
|
||||
@products.select! { |p| order_cycle_products.include? p }
|
||||
end
|
||||
redirect_to main_app.enterprise_path(current_distributor)
|
||||
} } }
|
||||
|
||||
end
|
||||
|
||||
@@ -7,4 +7,14 @@ describe Spree::ProductsController do
|
||||
response.should redirect_to spree.root_path
|
||||
end
|
||||
end
|
||||
|
||||
context "when a distributor has been chosen" do
|
||||
it "redirects #index to the distributor page" do
|
||||
d = create(:distributor_enterprise)
|
||||
controller.stub(:current_distributor) { d }
|
||||
|
||||
spree_get :index
|
||||
response.should redirect_to enterprise_path(d)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user