When editing an order cycle, distributor collection details are loaded

This commit is contained in:
Rohan Mitchell
2013-01-22 09:34:07 +11:00
parent c75738893e
commit 662aaf75bf
3 changed files with 13 additions and 5 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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)