Rename service and methods to remove use of "shop" term

This commit is contained in:
Matt-Yorkley
2019-10-01 14:43:47 +01:00
parent 6153789055
commit c038b485b1
4 changed files with 13 additions and 13 deletions

View File

@@ -1,7 +1,7 @@
# Returns a (paginatable) AR object for the products or variants in stock for a given shop and OC.
# The stock-checking includes on_demand and stock level overrides from variant_overrides.
class ShopProductsService
class OrderCycleDistributedProducts
def initialize(distributor, order_cycle)
@distributor = distributor
@order_cycle = order_cycle

View File

@@ -10,10 +10,10 @@ module OpenFoodNetwork
end
def products_json
if shop_products
if products
enterprise_fee_calculator = EnterpriseFeeCalculator.new @distributor, @order_cycle
ActiveModel::ArraySerializer.new(shop_products,
ActiveModel::ArraySerializer.new(products,
each_serializer: Api::ProductSerializer,
current_order_cycle: @order_cycle,
current_distributor: @distributor,
@@ -27,20 +27,20 @@ module OpenFoodNetwork
private
def shop_products
def products
return unless @order_cycle
@shop_products ||= begin
@products ||= begin
scoper = ScopeProductToHub.new(@distributor)
shop_products_service.products_relation.
distributed_products.products_relation.
order(taxon_order).
each { |product| scoper.scope(product) }
end
end
def shop_products_service
ShopProductsService.new(@distributor, @order_cycle)
def distributed_products
OrderCycleDistributedProducts.new(@distributor, @order_cycle)
end
def taxon_order
@@ -58,9 +58,9 @@ module OpenFoodNetwork
@variants_for_shop ||= begin
scoper = OpenFoodNetwork::ScopeVariantToHub.new(@distributor)
shop_products_service.variants_relation.
distributed_products.variants_relation.
includes(:default_price, :stock_locations, :product).
where(product_id: shop_products).
where(product_id: products).
each { |v| scoper.scope(v) }
end
end

View File

@@ -25,13 +25,13 @@ module OpenFoodNetwork
it "sorts products by the distributor's preferred taxon list" do
allow(distributor).to receive(:preferred_shopfront_taxon_order) { "#{t1.id},#{t2.id}" }
products = pr.send(:shop_products)
products = pr.send(:products)
expect(products).to eq([p2, p4, p1, p3])
end
it "alphabetizes products by name when taxon list is not set" do
allow(distributor).to receive(:preferred_shopfront_taxon_order) { "" }
products = pr.send(:shop_products)
products = pr.send(:products)
expect(products).to eq([p1, p2, p3, p4])
end
end

View File

@@ -1,6 +1,6 @@
require 'spec_helper'
describe ShopProductsService do
describe OrderCycleDistributedProducts do
describe "#products_relation" do
let(:distributor) { create(:distributor_enterprise) }
let(:product) { create(:product) }