From b27737740bf5b67a31750e9b061a6dbd4550206f Mon Sep 17 00:00:00 2001 From: YOSHIDA Hiroki Date: Mon, 26 Oct 2015 15:42:02 +0900 Subject: [PATCH 1/2] Improve title of the test case to checkout --- frontend/spec/features/checkout_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/spec/features/checkout_spec.rb b/frontend/spec/features/checkout_spec.rb index 00ade453..2361f8c9 100644 --- a/frontend/spec/features/checkout_spec.rb +++ b/frontend/spec/features/checkout_spec.rb @@ -14,7 +14,7 @@ context "when order state was 'cart'" do background { order.update_attributes(state: 'cart', email: nil) } - scenario 'Sign in via checkout flow' do + scenario 'requires sign in to checkout flow' do visit comable.cart_path click_button Comable.t('checkout') @@ -34,7 +34,7 @@ context "when order state was 'confirm'" do background { order.update_attributes(state: 'confirm') } - scenario 'Update the billing address' do + scenario 'redirects the confirm page after update the billing address' do visit comable.next_order_path(state: :orderer) within('form') do From 2a9ecaf978ab831eff6313e11de584e4d283746b Mon Sep 17 00:00:00 2001 From: YOSHIDA Hiroki Date: Mon, 26 Oct 2015 16:40:24 +0900 Subject: [PATCH 2/2] Add a test case to decreace the stock quantity in checkout --- frontend/spec/features/checkout_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/frontend/spec/features/checkout_spec.rb b/frontend/spec/features/checkout_spec.rb index 2361f8c9..5f3cddf6 100644 --- a/frontend/spec/features/checkout_spec.rb +++ b/frontend/spec/features/checkout_spec.rb @@ -46,4 +46,23 @@ expect(order.state).to eq('confirm') end end + + context "when order state was 'confirm'" do + background { order.update_attributes(state: 'confirm') } + + scenario 'decreaces the product quantity after complete order' do + quantity = 10 + stock = create(:stock, :with_product, quantity: quantity) + order_item = build(:order_item, variant: stock.variant, quantity: quantity) + order.order_items << order_item + + visit comable.next_order_path(state: :confirm) + + click_button Comable.t('complete_order') + + expect(current_url).to eq(comable.order_url) + expect(order.state).to eq('completed') + expect(stock.reload.quantity).to eq(0) + end + end end