From b025df17980f84d2d39490d9b48107ee5deff9ba Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Wed, 29 May 2019 10:48:51 +0100 Subject: [PATCH] Fix a few more rubocop issues --- app/models/spree/product_decorator.rb | 6 ++++-- lib/open_food_network/order_cycle_permissions.rb | 9 ++++++--- lib/open_food_network/products_cache.rb | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/models/spree/product_decorator.rb b/app/models/spree/product_decorator.rb index ef75d1601e..2e701eb920 100644 --- a/app/models/spree/product_decorator.rb +++ b/app/models/spree/product_decorator.rb @@ -189,7 +189,9 @@ Spree::Product.class_eval do OpenFoodNetwork::ProductsCache.product_deleted(self) do touch_distributors - ExchangeVariant.where('exchange_variants.variant_id IN (?)', variants_including_master.with_deleted.select(:id)).destroy_all + ExchangeVariant. + where('exchange_variants.variant_id IN (?)', variants_including_master.with_deleted. + select(:id)).destroy_all destroy_without_delete_from_order_cycles end @@ -216,7 +218,7 @@ Spree::Product.class_eval do end def touch_distributors - Enterprise.distributing_products(self.id).each(&:touch) + Enterprise.distributing_products(id).each(&:touch) end def add_primary_taxon_to_taxons diff --git a/lib/open_food_network/order_cycle_permissions.rb b/lib/open_food_network/order_cycle_permissions.rb index db0d4428ac..e49ee2f74f 100644 --- a/lib/open_food_network/order_cycle_permissions.rb +++ b/lib/open_food_network/order_cycle_permissions.rb @@ -55,7 +55,8 @@ module OpenFoodNetwork # TODO: Remove this when all P-OC are sorted out # Any hubs that currently have outgoing exchanges distributing variants of producers I manage variants = Spree::Variant.joins(:product).where('spree_products.supplier_id IN (?)', managed_enterprises.is_primary_producer) - active_exchanges = @order_cycle.exchanges.outgoing.with_any_variant(variants.select("spree_variants.id")) + active_exchanges = @order_cycle. + exchanges.outgoing.with_any_variant(variants.select("spree_variants.id")) hubs_active = active_exchanges.map(&:receiver_id) # TODO: Remove this when all P-OC are sorted out @@ -248,8 +249,10 @@ module OpenFoodNetwork # active_exchanges is for backward compatability, before we restricted variants in each # outgoing exchange to those where the producer had granted P-OC to the distributor # For any of my managed producers, any outgoing exchanges with their variants - variants = Spree::Variant.joins(:product).where('spree_products.supplier_id IN (?)', producers) - active_exchanges = @order_cycle.exchanges.outgoing.with_any_variant(variants.select("spree_variants.id")).pluck :id + variants = Spree::Variant. + joins(:product).where('spree_products.supplier_id IN (?)', producers) + active_exchanges = @order_cycle. + exchanges.outgoing.with_any_variant(variants.select("spree_variants.id")).pluck :id permitted_exchanges | active_exchanges end diff --git a/lib/open_food_network/products_cache.rb b/lib/open_food_network/products_cache.rb index b818b6bdf8..8dbf166d43 100644 --- a/lib/open_food_network/products_cache.rb +++ b/lib/open_food_network/products_cache.rb @@ -94,7 +94,8 @@ module OpenFoodNetwork end def self.inventory_item_changed(inventory_item) - exchanges_featuring_variants(inventory_item.variant.id, distributor: inventory_item.enterprise).each do |exchange| + exchanges_featuring_variants(inventory_item.variant.id, + distributor: inventory_item.enterprise).each do |exchange| refresh_cache exchange.receiver, exchange.order_cycle end end