Commit 419bd62f by vulehuan

rspec: card - step 2 - prevent user direct access when no items in card

parent 8f453dc8
......@@ -98,7 +98,8 @@ class CardsController < ApplicationController
@card_infos = session[:SHOPPING_CARD_SESSION_NAME]
end
if @card_infos.empty?
redirect_to cards_path
flash[:error] = "Please order before check out"
redirect_to products_path and return
end
if request.post?
@errors = Array.new
......
......@@ -156,6 +156,15 @@ describe "CardPages" do
describe "step 2" do
describe "when not pass step 1" do
before do
Product.all.each do |product|
visit cards_path(card_action: 'remove', product_id: product.id)
end
visit url_for(controller: 'cards', action: 'checkout')
end
it { should have_selector('.alert.alert-error', text: 'Please order') }
end
describe "when click Continue" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment