mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-03 06:59:14 +00:00
Remove unused helpers and standardise naming
This commit is contained in:
@@ -11,7 +11,7 @@ module OrderCyclesHelper
|
||||
order_cycle_permitted_enterprises.is_primary_producer.by_name
|
||||
end
|
||||
|
||||
def coordinating_enterprises
|
||||
def order_cycle_coordinating_enterprises
|
||||
order_cycle_hub_enterprises
|
||||
end
|
||||
|
||||
@@ -19,16 +19,6 @@ module OrderCyclesHelper
|
||||
order_cycle_permitted_enterprises.is_distributor.by_name
|
||||
end
|
||||
|
||||
def order_cycle_local_remote_class(distributor, order_cycle)
|
||||
if distributor.nil? || order_cycle.nil?
|
||||
''
|
||||
elsif order_cycle.distributors.include? distributor
|
||||
' local'
|
||||
else
|
||||
' remote'
|
||||
end
|
||||
end
|
||||
|
||||
def order_cycle_status_class(order_cycle)
|
||||
if order_cycle.undated?
|
||||
'undated'
|
||||
@@ -42,11 +32,6 @@ module OrderCyclesHelper
|
||||
end
|
||||
|
||||
|
||||
def distributor_options(distributors, current_distributor, order_cycle)
|
||||
options = distributors.map { |d| [d.name, d.id, {:class => order_cycle_local_remote_class(d, order_cycle).strip}] }
|
||||
options_for_select(options, current_distributor)
|
||||
end
|
||||
|
||||
def order_cycle_options
|
||||
@order_cycles.
|
||||
with_distributor(current_distributor).
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
%h2 Coordinator
|
||||
= f.label :coordinator_id, 'Coordinator'
|
||||
= f.collection_select :coordinator_id, coordinating_enterprises, :id, :name, {include_blank: true}, {'ng-model' => 'order_cycle.coordinator_id', 'ofn-on-change' => 'order_cycle.coordinator_fees = []', 'required' => true}
|
||||
= f.collection_select :coordinator_id, order_cycle_coordinating_enterprises, :id, :name, {include_blank: true}, {'ng-model' => 'order_cycle.coordinator_id', 'ofn-on-change' => 'order_cycle.coordinator_fees = []', 'required' => true}
|
||||
= render 'coordinator_fees', f: f
|
||||
|
||||
|
||||
|
||||
@@ -1,28 +1,8 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe OrderCyclesHelper do
|
||||
describe "generating local/remote classes for order cycle selection" do
|
||||
it "returns blank when no distributor or order cycle is selected" do
|
||||
helper.order_cycle_local_remote_class(nil, double(:order_cycle)).should == ''
|
||||
helper.order_cycle_local_remote_class(double(:distributor), nil).should == ''
|
||||
end
|
||||
|
||||
it "returns local when the order cycle includes the current distributor" do
|
||||
distributor = double(:enterprise)
|
||||
order_cycle = double(:order_cycle, distributors: [distributor])
|
||||
|
||||
helper.order_cycle_local_remote_class(distributor, order_cycle).should == ' local'
|
||||
end
|
||||
|
||||
it "returns remote when the order cycle does not include the current distributor" do
|
||||
distributor = double(:enterprise)
|
||||
order_cycle = double(:order_cycle, distributors: [])
|
||||
|
||||
helper.order_cycle_local_remote_class(distributor, order_cycle).should == ' remote'
|
||||
end
|
||||
end
|
||||
|
||||
it "gives me the pickup time for an order_cycle" do
|
||||
describe "pickup time" do
|
||||
it "gives me the pickup time for the current order cycle" do
|
||||
d = create(:distributor_enterprise, name: 'Green Grass')
|
||||
oc1 = create(:simple_order_cycle, name: 'oc 1', distributors: [d])
|
||||
exchange = Exchange.find(oc1.exchanges.to_enterprises(d).outgoing.first.id)
|
||||
@@ -31,9 +11,9 @@ describe OrderCyclesHelper do
|
||||
helper.stub(:current_order_cycle).and_return oc1
|
||||
helper.stub(:current_distributor).and_return d
|
||||
helper.pickup_time.should == "turtles"
|
||||
end
|
||||
end
|
||||
|
||||
it "should give me the pickup time for any order cycle" do
|
||||
it "gives me the pickup time for any order cycle" do
|
||||
d = create(:distributor_enterprise, name: 'Green Grass')
|
||||
oc1 = create(:simple_order_cycle, name: 'oc 1', distributors: [d])
|
||||
oc2= create(:simple_order_cycle, name: 'oc 1', distributors: [d])
|
||||
@@ -44,5 +24,6 @@ describe OrderCyclesHelper do
|
||||
helper.stub(:current_order_cycle).and_return oc1
|
||||
helper.stub(:current_distributor).and_return d
|
||||
helper.pickup_time(oc2).should == "turtles"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user