Skip to content

Commit

Permalink
Merge pull request #47 from hyoshida/improve-test-cases-for-checkout
Browse files Browse the repository at this point in the history
Improve test cases for checkout
  • Loading branch information
YOSHIDA Cake committed Oct 26, 2015
2 parents b6fa618 + 2a9ecaf commit 9142f39
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions frontend/spec/features/checkout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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
Expand All @@ -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

0 comments on commit 9142f39

Please sign in to comment.