mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-08 07:46:59 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4be45303bf | ||
|
|
8d19bcdcf2 | ||
|
|
f6f1cf9e41 |
@@ -201,7 +201,7 @@ module Spree
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_order
|
def update_order
|
||||||
order.update!
|
order.reload.update!
|
||||||
end
|
end
|
||||||
|
|
||||||
# Necessary because some payment gateways will refuse payments with
|
# Necessary because some payment gateways will refuse payments with
|
||||||
|
|||||||
@@ -35,4 +35,33 @@ feature '
|
|||||||
expect(page).to have_content I18n.t(:new_payment)
|
expect(page).to have_content I18n.t(:new_payment)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "creating an order's first payment via admin", js: true do
|
||||||
|
before do
|
||||||
|
order.update_columns(
|
||||||
|
state: "payment",
|
||||||
|
payment_state: nil,
|
||||||
|
shipment_state: nil,
|
||||||
|
completed_at: nil
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "creates the payment, completes the order, and updates payment and shipping states" do
|
||||||
|
login_as_admin_and_visit spree.new_admin_order_payment_path order
|
||||||
|
|
||||||
|
expect(page).to have_content "New Payment"
|
||||||
|
|
||||||
|
within "#new_payment" do
|
||||||
|
find('input[type="radio"]').click
|
||||||
|
end
|
||||||
|
|
||||||
|
click_button "Update"
|
||||||
|
expect(page).to have_content "Payments"
|
||||||
|
|
||||||
|
order.reload
|
||||||
|
expect(order.state).to eq "complete"
|
||||||
|
expect(order.payment_state).to eq "balance_due"
|
||||||
|
expect(order.shipment_state).to eq "pending"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -255,6 +255,10 @@ feature "As a consumer I want to check out my cart", js: true do
|
|||||||
place_order
|
place_order
|
||||||
expect(page).to have_content "Your order has been processed successfully"
|
expect(page).to have_content "Your order has been processed successfully"
|
||||||
end.to enqueue_job ConfirmOrderJob
|
end.to enqueue_job ConfirmOrderJob
|
||||||
|
|
||||||
|
order = Spree::Order.complete.last
|
||||||
|
expect(order.payment_state).to eq "balance_due"
|
||||||
|
expect(order.shipment_state).to eq "pending"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -389,10 +393,10 @@ feature "As a consumer I want to check out my cart", js: true do
|
|||||||
end.to enqueue_job ConfirmOrderJob
|
end.to enqueue_job ConfirmOrderJob
|
||||||
|
|
||||||
# And the order's special instructions should be set
|
# And the order's special instructions should be set
|
||||||
order = Spree::Order.complete.first
|
order = Spree::Order.complete.last
|
||||||
expect(order.special_instructions).to eq "SpEcIaL NoTeS"
|
expect(order.special_instructions).to eq "SpEcIaL NoTeS"
|
||||||
|
|
||||||
# Shipment and payments states should be set
|
# Shipment and payments states should be set ###
|
||||||
expect(order.payment_state).to eq "balance_due"
|
expect(order.payment_state).to eq "balance_due"
|
||||||
expect(order.shipment_state).to eq "pending"
|
expect(order.shipment_state).to eq "pending"
|
||||||
|
|
||||||
@@ -421,6 +425,10 @@ feature "As a consumer I want to check out my cart", js: true do
|
|||||||
it "takes us to the order confirmation page when submitted with 'same as billing address' checked" do
|
it "takes us to the order confirmation page when submitted with 'same as billing address' checked" do
|
||||||
place_order
|
place_order
|
||||||
expect(page).to have_content "Your order has been processed successfully"
|
expect(page).to have_content "Your order has been processed successfully"
|
||||||
|
|
||||||
|
order = Spree::Order.complete.last
|
||||||
|
expect(order.payment_state).to eq "balance_due"
|
||||||
|
expect(order.shipment_state).to eq "pending"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "takes us to the cart page with an error when a product becomes out of stock just before we purchase", js: true do
|
it "takes us to the cart page with an error when a product becomes out of stock just before we purchase", js: true do
|
||||||
@@ -443,9 +451,11 @@ feature "As a consumer I want to check out my cart", js: true do
|
|||||||
expect(page).to have_content "Your order has been processed successfully"
|
expect(page).to have_content "Your order has been processed successfully"
|
||||||
|
|
||||||
# There are two orders - our order and our new cart
|
# There are two orders - our order and our new cart
|
||||||
o = Spree::Order.complete.first
|
order = Spree::Order.complete.last
|
||||||
expect(o.shipment_adjustments.first.amount).to eq(4.56)
|
expect(order.shipment_adjustments.first.amount).to eq(4.56)
|
||||||
expect(o.payments.first.amount).to eq(10 + 1.23 + 4.56) # items + fees + shipping
|
expect(order.payments.first.amount).to eq(10 + 1.23 + 4.56) # items + fees + shipping
|
||||||
|
expect(order.payment_state).to eq "balance_due"
|
||||||
|
expect(order.shipment_state).to eq "pending"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -464,9 +474,11 @@ feature "As a consumer I want to check out my cart", js: true do
|
|||||||
expect(page).to have_content "Your order has been processed successfully"
|
expect(page).to have_content "Your order has been processed successfully"
|
||||||
|
|
||||||
# There are two orders - our order and our new cart
|
# There are two orders - our order and our new cart
|
||||||
o = Spree::Order.complete.first
|
order = Spree::Order.complete.last
|
||||||
expect(o.all_adjustments.payment_fee.first.amount).to eq 5.67
|
expect(order.all_adjustments.payment_fee.first.amount).to eq 5.67
|
||||||
expect(o.payments.first.amount).to eq(10 + 1.23 + 5.67) # items + fees + transaction
|
expect(order.payments.first.amount).to eq(10 + 1.23 + 5.67) # items + fees + transaction
|
||||||
|
expect(order.payment_state).to eq "balance_due"
|
||||||
|
expect(order.shipment_state).to eq "pending"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -485,8 +497,10 @@ feature "As a consumer I want to check out my cart", js: true do
|
|||||||
expect(page).to have_content "Your order has been processed successfully"
|
expect(page).to have_content "Your order has been processed successfully"
|
||||||
|
|
||||||
# Order should have a payment with the correct amount
|
# Order should have a payment with the correct amount
|
||||||
o = Spree::Order.complete.first
|
order = Spree::Order.complete.last
|
||||||
expect(o.payments.first.amount).to eq(11.23)
|
expect(order.payments.first.amount).to eq(11.23)
|
||||||
|
expect(order.payment_state).to eq "paid"
|
||||||
|
expect(order.shipment_state).to eq "ready"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "shows the payment processing failed message when submitted with an invalid credit card" do
|
it "shows the payment processing failed message when submitted with an invalid credit card" do
|
||||||
|
|||||||
Reference in New Issue
Block a user