Create shipment when creating a order for a subscription

A spec has been added to check that the attributes for the order states
after "cart" ("address", "delivery", "payment") are retained if the
order is transitioned to completion, BUT currently this is passing
because it is the only shipping method available.
This commit is contained in:
Kristina Lim
2019-02-26 15:51:59 +08:00
parent 0306cc7ca7
commit f42eb3dab1
2 changed files with 19 additions and 0 deletions

View File

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

View File

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