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
a823ed3d
Commit
a823ed3d
authored
Nov 01, 2013
by
vulehuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rspec: card - update 'update quantity' test syntax
parent
ef76ace2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
25 deletions
+52
-25
venshop_app/spec/factories.rb
+1
-1
venshop_app/spec/requests/card_pages_spec.rb
+51
-24
No files found.
venshop_app/spec/factories.rb
View file @
a823ed3d
...
...
@@ -26,7 +26,7 @@ FactoryGirl.define do
review_rate
0
review_count
0
price_currency
'USD'
price
99.99
price
111
product_category_id
0
user_id
0
status
true
...
...
venshop_app/spec/requests/card_pages_spec.rb
View file @
a823ed3d
...
...
@@ -4,7 +4,7 @@ describe "CardPages" do
subject
{
page
}
describe
"step 1"
do
before
(
:
all
)
{
before
(
:
each
)
do
@product_category
=
FactoryGirl
.
create
(
:product_category
)
@user
=
FactoryGirl
.
create
(
:user
)
5
.
times
{
FactoryGirl
.
create
(
:product
,
product_category_id:
@product_category
.
id
,
user_id:
@user
.
id
)
}
...
...
@@ -12,8 +12,8 @@ describe "CardPages" do
visit
product_path
(
product
)
page
.
find
(
'.product-detail'
).
click_link
(
'Order'
)
end
}
after
(
:
all
)
do
end
after
(
:
each
)
do
Product
.
delete_all
User
.
delete_all
ProductCategory
.
delete_all
...
...
@@ -58,16 +58,18 @@ describe "CardPages" do
end
end
it
"with valid information"
do
amount
=
99
product
=
Product
.
first
describe
"with valid information"
do
let
(
:amount
)
{
99
}
let
(
:product
)
{
Product
.
first
}
visit
cards_path
(
product_id:
product
.
id
)
before
do
visit
cards_path
(
card_action:
'update'
,
product_id:
product
.
id
,
quantity:
amount
)
end
page
.
should
have_xpath
(
"//input[@id='cart-quantity-
#{
product
.
id
}
'][@value='
#{
amount
}
']"
)
page
.
should
have_selector
(
".cart-unit-price-
#{
product
.
id
}
"
,
text:
ActionController
::
Base
.
helpers
.
number_with_delimiter
(
product
.
price
))
page
.
should
have_selector
(
".cart-total-price-
#{
product
.
id
}
"
,
text:
ActionController
::
Base
.
helpers
.
number_with_delimiter
(
product
.
price
*
amount
))
it
do
should
have_xpath
(
"//input[@id='cart-quantity-
#{
product
.
id
}
'][@value='
#{
amount
}
']"
)
should
have_selector
(
".cart-unit-price-
#{
product
.
id
}
"
,
text:
ActionController
::
Base
.
helpers
.
number_with_delimiter
(
product
.
price
))
should
have_selector
(
".cart-total-price-
#{
product
.
id
}
"
,
text:
ActionController
::
Base
.
helpers
.
number_with_delimiter
(
product
.
price
*
amount
))
total
=
0
Product
.
all
.
each
do
|
obj
|
...
...
@@ -75,37 +77,62 @@ describe "CardPages" do
end
total
+=
(
amount
-
1
)
*
product
.
price
page
.
should
have_selector
(
'#card-must-paid'
,
text:
ActionController
::
Base
.
helpers
.
number_with_delimiter
(
total
))
should
have_selector
(
'#card-must-paid'
,
text:
ActionController
::
Base
.
helpers
.
number_with_delimiter
(
total
))
end
end
end
describe
"when remove a product"
do
describe
"with invalid information"
do
# let(:product) { Product.first }
# before { visit cards_path(product_id: product.id) }
describe
"when product not exist"
do
before
do
visit
cards_path
(
card_action:
'update'
,
product_id:
0
,
quantity:
"abc"
)
end
#
before do
#
visit cards_path(card_action: 'update', product_id: 0, quantity: "abc")
#
end
it
{
should
have_selector
(
'.alert.alert-error'
,
text:
'Invalid'
)
}
#
it { should have_selector('.alert.alert-error', text: 'Invalid') }
end
it
"when product exist in db, but not exist in card"
do
product
=
Product
.
first
product_not_in_card
=
Product
.
last
#
it "when product exist in db, but not exist in card" do
#
product = Product.first
#
product_not_in_card = Product.last
visit
cards_path
(
product_id:
product
.
id
)
visit
cards_path
(
card_action:
'remove'
,
product_id:
product_not_in_card
.
id
)
#
visit cards_path(product_id: product.id)
#
visit cards_path(card_action: 'remove', product_id: product_not_in_card.id)
page
.
should
have_selector
(
'.alert.alert-error'
,
text:
'Invalid'
)
end
# page.should have_selector('.alert.alert-error', text: 'Invalid')
# end
# describe "when product exist in db, but not exist in card" do
# let(:product_not_in_card) { Product.last }
# before do
# visit cards_path(card_action: 'remove', product_id: product_not_in_card.id)
# end
# it { should have_selector('.alert.alert-error', text: 'Invalid') }
# end
end
describe
"when product exist in card"
do
describe
"calculate price"
do
end
# it "calculate price" do
# product = Product.first
# total = 0
# # Add to cart all
# Product.all.each do |obj|
# visit cards_path(product_id: product.id)
# total += obj.price
# end
# visit cards_path(card_action: 'remove', product_id: product.id)
# total -= product.price
# page.should have_selector('#card-must-paid', text: ActionController::Base.helpers.number_with_delimiter(total + 1))
# 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