From 6f7c8bb8b1e174dc67e60effa4a1e57844878a0e Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Mon, 3 Jul 2017 13:05:15 +0200 Subject: [PATCH] Get shipping method from Shipment in order details This again gets the shipping method from the last shipment. It also extracts partials for delivery and pickup shipping methods. --- .../_delivery_shipment_details.html.haml | 25 ++++++++ .../spree/shared/_order_details.html.haml | 57 ++----------------- .../shared/_pickup_shipment_details.html.haml | 25 ++++++++ .../features/consumer/shopping/orders_spec.rb | 5 ++ 4 files changed, 59 insertions(+), 53 deletions(-) create mode 100644 app/views/spree/shared/_delivery_shipment_details.html.haml create mode 100644 app/views/spree/shared/_pickup_shipment_details.html.haml diff --git a/app/views/spree/shared/_delivery_shipment_details.html.haml b/app/views/spree/shared/_delivery_shipment_details.html.haml new file mode 100644 index 0000000000..94c2de4d96 --- /dev/null +++ b/app/views/spree/shared/_delivery_shipment_details.html.haml @@ -0,0 +1,25 @@ +.order-summary.text-small + %strong= shipment.shipping_method.name +.pad + .text-big + = t :order_delivery_time + %strong #{order.order_cycle.pickup_time_for(order.distributor)} + %p.text-small.text-skinny.pre-line + %em= shipment.shipping_method.description.andand.html_safe || "" +.order-summary.text-small + %strong + = t :order_delivery_address +.pad + %p.text-small + = order.ship_address.firstname + " " + order.ship_address.lastname + %br + = order.ship_address.full_address + %br + = order.ship_address.phone + - if order.special_instructions.present? + %br + %p.light.small + %strong + = t :order_special_instructions + %br + = order.special_instructions diff --git a/app/views/spree/shared/_order_details.html.haml b/app/views/spree/shared/_order_details.html.haml index 63e0f4450b..b416197a8c 100644 --- a/app/views/spree/shared/_order_details.html.haml +++ b/app/views/spree/shared/_order_details.html.haml @@ -29,60 +29,11 @@ = order.bill_address.phone .columns.large-6 - - if order.shipping_method.andand.require_ship_address - // Delivery option - .order-summary.text-small - %strong= order.shipping_method.name - .pad - .text-big - = t :order_delivery_time - %strong #{order.order_cycle.pickup_time_for(order.distributor)} - %p.text-small.text-skinny.pre-line - %em= order.shipping_method.description.andand.html_safe || "" - .order-summary.text-small - %strong - = t :order_delivery_address - .pad - %p.text-small - = order.ship_address.firstname + " " + order.ship_address.lastname - %br - = order.ship_address.full_address - %br - = order.ship_address.phone - - if order.special_instructions.present? - %br - %p.light.small - %strong - = t :order_special_instructions - %br - = order.special_instructions + - shipment = order.shipments.last + - if shipment.shipping_method.andand.require_ship_address + = render 'spree/shared/delivery_shipment_details', order: order, shipment: shipment - else - // Collection option - .order-summary.text-small - %strong= order.shipping_method.name - .pad - .text-big - = t :order_pickup_time - %strong #{order.order_cycle.pickup_time_for(order.distributor)} - %p.text-small.text-skinny.pre-line - %em= order.shipping_method.description.andand.html_safe || "" - - - if order.order_cycle.pickup_instructions_for(order.distributor).present? - %br - %p.text-small - %strong - = t :order_pickup_instructions - %br - #{order.order_cycle.pickup_instructions_for(order.distributor)} - - - if order.special_instructions.present? - %br - %p.light.small - %strong - = t :order_special_instructions - %br - = order.special_instructions - + = render 'spree/shared/pickup_shipment_details', order: order, shipment: shipment %br .row .columns.large-12 diff --git a/app/views/spree/shared/_pickup_shipment_details.html.haml b/app/views/spree/shared/_pickup_shipment_details.html.haml new file mode 100644 index 0000000000..0719c58458 --- /dev/null +++ b/app/views/spree/shared/_pickup_shipment_details.html.haml @@ -0,0 +1,25 @@ +.order-summary.text-small + %strong= order.shipments.last.shipping_method.name +.pad + .text-big + = t :order_pickup_time + %strong #{order.order_cycle.pickup_time_for(order.distributor)} + %p.text-small.text-skinny.pre-line + %em= order.shipments.last.shipping_method.description.andand.html_safe || "" + + - if order.order_cycle.pickup_instructions_for(order.distributor).present? + %br + %p.text-small + %strong + = t :order_pickup_instructions + %br + #{order.order_cycle.pickup_instructions_for(order.distributor)} + + - if order.special_instructions.present? + %br + %p.light.small + %strong + = t :order_special_instructions + %br + = order.special_instructions + diff --git a/spec/features/consumer/shopping/orders_spec.rb b/spec/features/consumer/shopping/orders_spec.rb index 379f1b5197..2590e0d8fb 100644 --- a/spec/features/consumer/shopping/orders_spec.rb +++ b/spec/features/consumer/shopping/orders_spec.rb @@ -21,6 +21,11 @@ feature "Order Management", js: true do quick_login_as user end + it 'shows the name of the shipping method' do + visit spree.order_path(order) + expect(find('#order')).to have_content(shipping_method.name) + end + context "when the distributor doesn't allow changes to be made to orders" do before do order.distributor.update_attributes(allow_order_changes: false)