From 662aaf75bf28d3dfbb3a7ab6388575518e24e198 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Tue, 22 Jan 2013 09:34:07 +1100 Subject: [PATCH] When editing an order cycle, distributor collection details are loaded --- app/views/admin/order_cycles/show.rep | 3 +++ spec/factories.rb | 6 +++--- spec/features/admin/order_cycles_spec.rb | 9 +++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/views/admin/order_cycles/show.rep b/app/views/admin/order_cycles/show.rep index f83f21e9b6..ba396c5f12 100644 --- a/app/views/admin/order_cycles/show.rep +++ b/app/views/admin/order_cycles/show.rep @@ -10,5 +10,8 @@ r.element :order_cycle, @order_cycle do r.element :receiver_id r.element :variants, Hash[ exchange.variants.map { |v| [v.id, true] } ], {} + + r.element :pickup_time + r.element :pickup_instructions end end diff --git a/spec/factories.rb b/spec/factories.rb index 3e377273c9..67f87abd00 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -9,8 +9,8 @@ FactoryGirl.define do ex2 = create(:exchange, :order_cycle => oc, :receiver => oc.coordinator) # Distributors - create(:exchange, :order_cycle => oc, :sender => oc.coordinator) - create(:exchange, :order_cycle => oc, :sender => oc.coordinator) + create(:exchange, :order_cycle => oc, :sender => oc.coordinator, :pickup_time => 'time 0', :pickup_instructions => 'instructions 0') + create(:exchange, :order_cycle => oc, :sender => oc.coordinator, :pickup_time => 'time 1', :pickup_instructions => 'instructions 1') # Products with images [ex1, ex2].each do |exchange| @@ -29,7 +29,7 @@ FactoryGirl.define do orders_open_at { Time.zone.now - 1.day } orders_close_at { Time.zone.now + 1.week } - coordinator { Enterprise.first || FactoryGirl.create(:enterprise) } + coordinator { Enterprise.is_distributor.first || FactoryGirl.create(:distributor_enterprise) } end factory :exchange, :class => Exchange do diff --git a/spec/features/admin/order_cycles_spec.rb b/spec/features/admin/order_cycles_spec.rb index a0425e2ec3..3e4a9bdff1 100644 --- a/spec/features/admin/order_cycles_spec.rb +++ b/spec/features/admin/order_cycles_spec.rb @@ -32,7 +32,7 @@ feature %q{ scenario "creating an order cycle" do # Given coordinating, supplying and distributing enterprises with some products with variants - create(:enterprise, name: 'My coordinator') + create(:distributor_enterprise, name: 'My coordinator') supplier = create(:supplier_enterprise, name: 'My supplier') product = create(:product, supplier: supplier) create(:variant, product: product) @@ -128,6 +128,11 @@ feature %q{ page.should have_selector 'td.distributor_name', :text => oc.distributors.first.name page.should have_selector 'td.distributor_name', :text => oc.distributors.last.name + page.find('#order_cycle_outgoing_exchange_0_pickup_time').value.should == 'time 0' + page.find('#order_cycle_outgoing_exchange_0_pickup_instructions').value.should == 'instructions 0' + page.find('#order_cycle_outgoing_exchange_1_pickup_time').value.should == 'time 1' + page.find('#order_cycle_outgoing_exchange_1_pickup_instructions').value.should == 'instructions 1' + page.all('table.exchanges tbody tr.distributor').each do |row| row.find('td.products input').click @@ -144,7 +149,7 @@ feature %q{ oc = create(:order_cycle) # And a coordinating, supplying and distributing enterprise with some products with variants - create(:enterprise, name: 'My coordinator') + create(:distributor_enterprise, name: 'My coordinator') supplier = create(:supplier_enterprise, name: 'My supplier') distributor = create(:distributor_enterprise, name: 'My distributor') product = create(:product, supplier: supplier)