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
f2eb7965
Commit
f2eb7965
authored
Oct 30, 2013
by
vulehuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rspec: product controller
parent
500f85a3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
130 additions
and
3 deletions
+130
-3
venshop_app/spec/requests/product_pages_spec.rb
+130
-3
No files found.
venshop_app/spec/requests/product_pages_spec.rb
View file @
f2eb7965
...
...
@@ -4,19 +4,146 @@ describe "Products Page" do
subject
{
page
}
describe
"
index
page"
do
describe
"
product
page"
do
end
describe
"list"
do
before
{
visit
products_path
}
describe
"product page"
do
it
{
should
have_content
(
'Products'
)
}
it
{
should
have_title
(
full_title
(
'Products'
))
}
end
# describe "pagination" do
# before(:all) {
# @product_category = ProductCategory.new(
# name: "Product category name"
# )
# @product_category.save
# @user = User.new(name: "Example User", email: "user_product_test@example.com", password: "foobar", password_confirmation: "foobar")
# @user.save
# 300.times do |n|
# @product = Product.new(
# name: "Example #{n} User",
# description: "user@example.com",
# headline: "foobar",
# availability: "foobar",
# code: 'Code',
# condition: 'Condition',
# image_small: '',
# image_medium: 'Image Path',
# review_rate: 0,
# review_count: 0,
# price_currency: 'USD',
# price: 0,
# product_category_id: @product_category.id,
# user_id: @user.id,
# status: 1
# )
# @product.save
# end
# visit products_path
# }
# after(:all) do
# Product.delete_all
# User.delete_all
# ProductCategory.delete_all
# end
# it "should list each product" do
# Product.paginate(page: 1).each do |product|
# expect(page).to have_selector('.item h4 a')
# end
# end
# end
end
describe
"category page"
do
describe
"with valid category id"
do
before
do
@product_category
=
ProductCategory
.
new
(
name:
"Product category name"
)
@product_category
.
save
visit
product_category_path
(
@product_category
)
end
it
{
should
have_content
(
@product_category
.
name
)
}
it
{
should
have_title
(
@product_category
.
name
)
}
end
describe
"with invalid category id"
do
describe
"when category id is not a number"
do
before
do
visit
product_category_path
(
"abc"
)
end
it
{
should
have_selector
(
'.alert.alert-error'
,
text:
'Invalid'
)
}
end
describe
"when category id is not exist"
do
before
do
visit
product_category_path
(
0
)
end
it
{
should
have_selector
(
'.alert.alert-error'
,
text:
'Invalid'
)
}
end
end
end
describe
"detail page"
do
describe
"with valid product id"
do
before
do
@product_category
=
ProductCategory
.
new
(
name:
"Product category name"
)
@product_category
.
save
@user
=
User
.
new
(
name:
"Example User"
,
email:
"user_product_test@example.com"
,
password:
"foobar"
,
password_confirmation:
"foobar"
)
@user
.
save
@product
=
Product
.
new
(
name:
"Example User"
,
description:
"user@example.com"
,
headline:
"foobar"
,
availability:
"foobar"
,
code:
'Code'
,
condition:
'Condition'
,
image_small:
''
,
image_medium:
'Image Path'
,
review_rate:
0
,
review_count:
0
,
price_currency:
'USD'
,
price:
0
,
product_category_id:
@product_category
.
id
,
user_id:
@user
.
id
,
status:
1
)
@product
.
save
visit
product_path
(
@product
)
end
it
{
should
have_content
(
@product
.
name
)
}
it
{
should
have_title
(
@product
.
name
)
}
end
describe
"with invalid product id"
do
describe
"when product id is not a number"
do
before
do
visit
product_path
(
"abc"
)
end
it
{
should
have_selector
(
'.alert.alert-error'
,
text:
'Invalid'
)
}
end
describe
"when product id not exist"
do
before
do
visit
product_path
(
0
)
end
it
{
should
have_selector
(
'.alert.alert-error'
,
text:
'Invalid'
)
}
end
end
end
end
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