diff --git a/app/services/order_factory.rb b/app/services/order_factory.rb index 9aa5c9fb05..fc4bd5f424 100644 --- a/app/services/order_factory.rb +++ b/app/services/order_factory.rb @@ -15,8 +15,10 @@ class OrderFactory set_user build_line_items set_addresses + create_shipment set_shipping_method create_payment + @order end @@ -66,6 +68,10 @@ class OrderFactory @order.update_attributes(attrs.slice(:bill_address_attributes, :ship_address_attributes)) end + def create_shipment + @order.create_proposed_shipments + end + def set_shipping_method @order.select_shipping_method(attrs[:shipping_method_id]) end diff --git a/spec/services/order_factory_spec.rb b/spec/services/order_factory_spec.rb index 672ac0a780..1aa28486bd 100644 --- a/spec/services/order_factory_spec.rb +++ b/spec/services/order_factory_spec.rb @@ -42,6 +42,19 @@ describe OrderFactory do expect(order.complete?).to be false end + it "retains address, delivery, and payment attributes until completion of the order" do + while !order.completed? do break unless order.next! end + + order.reload + + expect(order.customer).to eq customer + expect(order.shipping_method).to eq shipping_method + expect(order.payments.first.payment_method).to eq payment_method + expect(order.bill_address).to eq bill_address + expect(order.ship_address).to eq ship_address + expect(order.total).to eq 38.0 + end + context "when the customer does not have a user associated with it" do before { customer.update_attribute(:user_id, nil) }