From 87d5ffeee2633515308d2714f88e5a8f6e58fae2 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 18 Jan 2013 14:24:17 +1100 Subject: [PATCH] Add fields for outgoing exchange collection details --- app/views/admin/order_cycles/_exchange_form.html.haml | 5 +++++ app/views/admin/order_cycles/_form.html.haml | 1 + spec/features/admin/order_cycles_spec.rb | 10 ++++++++++ 3 files changed, 16 insertions(+) diff --git a/app/views/admin/order_cycles/_exchange_form.html.haml b/app/views/admin/order_cycles/_exchange_form.html.haml index f9f515d8c4..47c24bb92a 100644 --- a/app/views/admin/order_cycles/_exchange_form.html.haml +++ b/app/views/admin/order_cycles/_exchange_form.html.haml @@ -8,3 +8,8 @@ - else {{ incomingExchangesVariants().length }} selected +- if type == 'distributor' + %td.collection-details + = text_field_tag 'order_cycle_outgoing_exchange_{{ $index }}_pickup_time', '', 'id' => 'order_cycle_outgoing_exchange_{{ $index }}_pickup_time', 'placeholder' => 'Pickup time / date', 'ng-model' => 'exchange.pickup_time' + %br/ + = text_field_tag 'order_cycle_outgoing_exchange_{{ $index }}_pickup_instructions', '', 'id' => 'order_cycle_outgoing_exchange_{{ $index }}_pickup_instructions', 'placeholder' => 'Delivery instructions', 'ng-model' => 'exchange.pickup_instructions' diff --git a/app/views/admin/order_cycles/_form.html.haml b/app/views/admin/order_cycles/_form.html.haml index b08fca0d7e..3ccf8d6ac5 100644 --- a/app/views/admin/order_cycles/_form.html.haml +++ b/app/views/admin/order_cycles/_form.html.haml @@ -39,6 +39,7 @@ %th %th Distributor %th Products + %th Collection details %tbody{'ng-repeat' => 'exchange in order_cycle.outgoing_exchanges'} %tr.distributor = render 'exchange_form', :f => f, :type => 'distributor' diff --git a/spec/features/admin/order_cycles_spec.rb b/spec/features/admin/order_cycles_spec.rb index 0fc13c4582..a0425e2ec3 100644 --- a/spec/features/admin/order_cycles_spec.rb +++ b/spec/features/admin/order_cycles_spec.rb @@ -60,6 +60,10 @@ feature %q{ # And I add a distributor with the same products select 'My distributor', from: 'new_distributor_id' click_button 'Add distributor' + + fill_in 'order_cycle_outgoing_exchange_0_pickup_time', with: 'pickup time' + fill_in 'order_cycle_outgoing_exchange_0_pickup_instructions', with: 'pickup instructions' + page.find('table.exchanges tr.distributor td.products input').click check 'order_cycle_outgoing_exchange_0_variants_2' check 'order_cycle_outgoing_exchange_0_variants_3' @@ -82,6 +86,12 @@ feature %q{ # And it should have some variants selected OrderCycle.last.exchanges.first.variants.count.should == 2 OrderCycle.last.exchanges.last.variants.count.should == 2 + + # And my pickup time and instructions should have been saved + oc = OrderCycle.last + exchange = oc.exchanges.where(:sender_id => oc.coordinator_id).first + exchange.pickup_time.should == 'pickup time' + exchange.pickup_instructions.should == 'pickup instructions' end