mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-10 23:07:47 +00:00
Rename SplitProductsByDistributor to SplitProductsByDistribution
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
require 'open_food_web/split_products_by_distributor'
|
||||
require 'open_food_web/split_products_by_distribution'
|
||||
|
||||
Spree::HomeController.class_eval do
|
||||
include EnterprisesHelper
|
||||
include OpenFoodWeb::SplitProductsByDistributor
|
||||
include OpenFoodWeb::SplitProductsByDistribution
|
||||
|
||||
respond_override :index => { :html => { :success => lambda {
|
||||
@products, @products_local, @products_remote = split_products_by_distributor @products, current_distributor
|
||||
@products, @products_local, @products_remote = split_products_by_distribution @products, current_distributor
|
||||
} } }
|
||||
end
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
require 'open_food_web/split_products_by_distributor'
|
||||
require 'open_food_web/split_products_by_distribution'
|
||||
|
||||
Spree::ProductsController.class_eval do
|
||||
include EnterprisesHelper
|
||||
include OpenFoodWeb::SplitProductsByDistributor
|
||||
include OpenFoodWeb::SplitProductsByDistribution
|
||||
|
||||
respond_override :index => { :html => { :success => lambda {
|
||||
@products, @products_local, @products_remote = split_products_by_distributor @products, current_distributor
|
||||
@products, @products_local, @products_remote = split_products_by_distribution @products, current_distributor
|
||||
} } }
|
||||
|
||||
end
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
require 'open_food_web/split_products_by_distributor'
|
||||
require 'open_food_web/split_products_by_distribution'
|
||||
|
||||
Spree::TaxonsController.class_eval do
|
||||
include EnterprisesHelper
|
||||
include OpenFoodWeb::SplitProductsByDistributor
|
||||
include OpenFoodWeb::SplitProductsByDistribution
|
||||
|
||||
respond_override :show => { :html => { :success => lambda {
|
||||
@products, @products_local, @products_remote = split_products_by_distributor @products, current_distributor
|
||||
@products, @products_local, @products_remote = split_products_by_distribution @products, current_distributor
|
||||
} } }
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ module Spree
|
||||
|
||||
# The concern of separating products by distributor and order cycle is dealt with in
|
||||
# a few other places: OpenFoodWeb::Searcher (for searching over products) and in
|
||||
# OpenFoodWeb::SplitProductsByDistributor (for splitting the main product display).
|
||||
# OpenFoodWeb::SplitProductsByDistribution (for splitting the main product display).
|
||||
|
||||
products = Product.in_taxon(taxon)
|
||||
products = products.in_distributor(current_distributor) if current_distributor
|
||||
|
||||
@@ -15,7 +15,7 @@ module OpenFoodWeb
|
||||
base_scope = super
|
||||
|
||||
# The concern of separating products by distributor and order cycle is dealt with in
|
||||
# a few other places: OpenFoodWeb::SplitProductsByDistributor (for splitting the main
|
||||
# a few other places: OpenFoodWeb::SplitProductsByDistribution (for splitting the main
|
||||
# product display) and Spree::BaseHelper decorator (for taxon counts).
|
||||
|
||||
base_scope = base_scope.in_supplier_or_distributor(enterprise_id) if enterprise_id
|
||||
|
||||
@@ -4,11 +4,11 @@ module OpenFoodWeb
|
||||
# other places: OpenFoodWeb::Searcher (for searching over products) and in
|
||||
# Spree::BaseHelper decorator (for taxon counts).
|
||||
|
||||
module SplitProductsByDistributor
|
||||
module SplitProductsByDistribution
|
||||
# If a distributor is provided, split the list of products into local (at that
|
||||
# distributor) and remote (at another distributor). If a distributor is not
|
||||
# provided, perform no split.
|
||||
def split_products_by_distributor(products, distributor)
|
||||
def split_products_by_distribution(products, distributor)
|
||||
products_local = products_remote = nil
|
||||
|
||||
if distributor
|
||||
@@ -1,14 +1,14 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe OpenFoodWeb::SplitProductsByDistributor do
|
||||
let(:products_splitter) { Class.new { include OpenFoodWeb::SplitProductsByDistributor } }
|
||||
describe OpenFoodWeb::SplitProductsByDistribution do
|
||||
let(:products_splitter) { Class.new { include OpenFoodWeb::SplitProductsByDistribution } }
|
||||
let(:subject) { products_splitter.new }
|
||||
|
||||
|
||||
it "does nothing when no distributor is selected" do
|
||||
orig_products = (1..3).map { |i| build(:product) }
|
||||
|
||||
products, products_local, products_remote = subject.split_products_by_distributor orig_products, nil
|
||||
products, products_local, products_remote = subject.split_products_by_distribution orig_products, nil
|
||||
|
||||
products.should == orig_products
|
||||
products_local.should be_nil
|
||||
@@ -21,7 +21,7 @@ describe OpenFoodWeb::SplitProductsByDistributor do
|
||||
orig_products = [build(:product, :distributors => [d1]),
|
||||
build(:product, :distributors => [d2])]
|
||||
|
||||
products, products_local, products_remote = subject.split_products_by_distributor orig_products, d1
|
||||
products, products_local, products_remote = subject.split_products_by_distribution orig_products, d1
|
||||
|
||||
products.should be_nil
|
||||
products_local.should == [orig_products[0]]
|
||||
Reference in New Issue
Block a user