Reduce complexity of EnterprisesController#shop

As asked by Rubocop.
This commit is contained in:
Pau Perez
2019-01-03 11:14:51 +01:00
parent e3edb51d3e
commit ddf916814f

View File

@@ -17,17 +17,12 @@ class EnterprisesController < BaseController
return redirect_to spree.cart_path unless enough_stock?
set_noindex_meta_tag
order_cycles = if current_order_cycle
[current_order_cycle]
else
OrderCycle.not_closed.with_distributor(current_distributor)
end
enterprises = current_distributor
.plus_relatives_and_oc_producers(order_cycles)
.plus_relatives_and_oc_producers(shop_order_cycles)
.activated
.includes(address: :state)
.all
enterprises = inject_json_ams('enterprises', enterprises)
render locals: { enterprises: enterprises }
@@ -102,6 +97,14 @@ class EnterprisesController < BaseController
order.order_cycle = order_cycle_options.first if order_cycle_options.count == 1
end
def shop_order_cycles
if current_order_cycle
[current_order_cycle]
else
OrderCycle.not_closed.with_distributor(current_distributor)
end
end
def set_noindex_meta_tag
@noindex_meta_tag = true unless current_distributor.visible?
end