Commit c53002c1 by vulehuan

rspec: card - step 2: when not pass step 1

parent 419bd62f
...@@ -97,7 +97,7 @@ class CardsController < ApplicationController ...@@ -97,7 +97,7 @@ class CardsController < ApplicationController
if !session[:SHOPPING_CARD_SESSION_NAME].nil? if !session[:SHOPPING_CARD_SESSION_NAME].nil?
@card_infos = session[:SHOPPING_CARD_SESSION_NAME] @card_infos = session[:SHOPPING_CARD_SESSION_NAME]
end end
if @card_infos.empty? if @card_infos.empty? || @card_infos[:card_items].empty?
flash[:error] = "Please order before check out" flash[:error] = "Please order before check out"
redirect_to products_path and return redirect_to products_path and return
end end
......
...@@ -32,6 +32,13 @@ FactoryGirl.define do ...@@ -32,6 +32,13 @@ FactoryGirl.define do
status true status true
end end
factory :my_card do
full_name "Joseph Vu"
email "vulehuan@gmail.com"
phone "01659572211"
address "2761 Pham The Hien Str., Ward 7, District 8"
note "asap"
end
end end
def sign_in(user, options={}) def sign_in(user, options={})
......
require 'spec_helper' require 'spec_helper'
require 'set'
def fill_in_order_form()
fill_in "Full name", with: "Joseph Vu"
fill_in "Email", with: "vulehuan@gmail.com"
fill_in "Phone", with: "01659572211"
fill_in "Address", with: "2761 Pham The Hien Str., Ward 7, District 8"
fill_in "Note", with: "asap"
end
describe "CardPages" do describe "CardPages" do
subject { page } subject { page }
describe "step 1" do
before(:all) do before(:all) do
@product_category = FactoryGirl.create(:product_category) @product_category = FactoryGirl.create(:product_category)
@user = FactoryGirl.create(:user) @user = FactoryGirl.create(:user)
...@@ -26,6 +33,7 @@ describe "CardPages" do ...@@ -26,6 +33,7 @@ describe "CardPages" do
Product.delete_all Product.delete_all
end end
describe "step 1" do
describe "when update quantity" do describe "when update quantity" do
describe "with invalid information" do describe "with invalid information" do
describe "when product not exist" do describe "when product not exist" do
...@@ -168,8 +176,28 @@ describe "CardPages" do ...@@ -168,8 +176,28 @@ describe "CardPages" do
end end
describe "when click Continue" do describe "when click Continue" do
before do
Product.all.each do |product|
visit product_path(product)
page.find('.product-detail').click_link('Order')
end
end
# let(:customer_info) { FactoryGirl.create(:my_card) }
describe "with invalid information" do describe "with invalid information" do
describe "when fullname is not present" do describe "when fullname is not present" do
# before do
# visit url_for(controller: 'cards', action: 'checkout')
# # puts page.html
# puts Product.all.count.to_s
# # fill_in_order_form()
# fill_in "full_name", with: ""
# end
# it {
# # puts html
# should have_selector('.alert.alert-error', text: 'Full name is required')
# }
end end
describe "when email is not present" do describe "when email is not present" 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