Commit c53002c1 by vulehuan

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

parent 419bd62f
......@@ -97,7 +97,7 @@ class CardsController < ApplicationController
if !session[:SHOPPING_CARD_SESSION_NAME].nil?
@card_infos = session[:SHOPPING_CARD_SESSION_NAME]
end
if @card_infos.empty?
if @card_infos.empty? || @card_infos[:card_items].empty?
flash[:error] = "Please order before check out"
redirect_to products_path and return
end
......
......@@ -32,6 +32,13 @@ FactoryGirl.define do
status true
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
def sign_in(user, options={})
......
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
subject { page }
before(:all) do
@product_category = FactoryGirl.create(:product_category)
@user = FactoryGirl.create(:user)
end
describe "step 1" do
before(:all) do
@product_category = FactoryGirl.create(:product_category)
@user = FactoryGirl.create(:user)
end
before(:each) do
5.times { FactoryGirl.create(:product, product_category_id: @product_category.id, user_id: @user.id) }
Product.all.each do |product|
visit product_path(product)
page.find('.product-detail').click_link('Order')
end
before(:each) do
5.times { FactoryGirl.create(:product, product_category_id: @product_category.id, user_id: @user.id) }
Product.all.each do |product|
visit product_path(product)
page.find('.product-detail').click_link('Order')
end
end
after(:all) do
User.delete_all
ProductCategory.delete_all
end
after(:all) do
User.delete_all
ProductCategory.delete_all
end
after(:each) do
Product.delete_all
end
after(:each) do
Product.delete_all
end
describe "step 1" do
describe "when update quantity" do
describe "with invalid information" do
describe "when product not exist" do
......@@ -168,8 +176,28 @@ describe "CardPages" do
end
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 "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
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