Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
venshop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
huanvl
venshop
Commits
c53002c1
Commit
c53002c1
authored
Nov 04, 2013
by
vulehuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rspec: card - step 2: when not pass step 1
parent
419bd62f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
20 deletions
+55
-20
venshop_app/app/controllers/cards_controller.rb
+1
-1
venshop_app/spec/factories.rb
+7
-0
venshop_app/spec/requests/card_pages_spec.rb
+47
-19
No files found.
venshop_app/app/controllers/cards_controller.rb
View file @
c53002c1
...
@@ -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
...
...
venshop_app/spec/factories.rb
View file @
c53002c1
...
@@ -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
=
{})
...
...
venshop_app/spec/requests/card_pages_spec.rb
View file @
c53002c1
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
}
before
(
:all
)
do
@product_category
=
FactoryGirl
.
create
(
:product_category
)
@user
=
FactoryGirl
.
create
(
:user
)
end
describe
"step 1"
do
before
(
:each
)
do
before
(
:all
)
do
5
.
times
{
FactoryGirl
.
create
(
:product
,
product_category_id:
@product_category
.
id
,
user_id:
@user
.
id
)
}
@product_category
=
FactoryGirl
.
create
(
:product_category
)
Product
.
all
.
each
do
|
product
|
@user
=
FactoryGirl
.
create
(
:user
)
visit
product_path
(
product
)
end
page
.
find
(
'.product-detail'
).
click_link
(
'Order'
)
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
end
end
after
(
:all
)
do
after
(
:all
)
do
User
.
delete_all
User
.
delete_all
ProductCategory
.
delete_all
ProductCategory
.
delete_all
end
end
after
(
:each
)
do
after
(
:each
)
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment