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
80df58aa
Commit
80df58aa
authored
Nov 04, 2013
by
vulehuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rspec: card - step 2: calculate price
parent
e11b2ec7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
venshop_app/app/views/cards/_item_list.html.erb
+3
-3
venshop_app/spec/requests/card_pages_spec.rb
+15
-0
No files found.
venshop_app/app/views/cards/_item_list.html.erb
View file @
80df58aa
...
...
@@ -31,10 +31,10 @@
<%
if
can_edit
%>
<td><input
id=
"cart-quantity-
<%=
card_item
[
:product_id
]
%>
"
type=
"text"
class=
"form-control txt-quantity"
value=
"
<%=
card_item
[
:quantity
]
%>
"
/></td>
<%
else
%>
<td><div
class=
"text-right"
>
<%=
card_item
[
:quantity
]
%>
</div></td>
<td><div
class=
"text-right"
id=
"cart-quantity-
<%=
card_item
[
:product_id
]
%>
"
>
<%=
card_item
[
:quantity
]
%>
</div></td>
<%
end
%>
<td><div
class=
"text-right
cart-unit-price-
<%=
card_item
[
:product_id
]
%>
"
>
<%=
number_with_delimiter
(
product
.
price
)
%>
</div></td>
<td><div
class=
"text-right
cart-total-price-
<%=
card_item
[
:product_id
]
%>
"
>
<%=
number_with_delimiter
(
product
.
price
*
card_item
[
:quantity
])
%>
</div></td>
<td><div
class=
"text-right
"
id=
"
cart-unit-price-
<%=
card_item
[
:product_id
]
%>
"
>
<%=
number_with_delimiter
(
product
.
price
)
%>
</div></td>
<td><div
class=
"text-right
"
id=
"
cart-total-price-
<%=
card_item
[
:product_id
]
%>
"
>
<%=
number_with_delimiter
(
product
.
price
*
card_item
[
:quantity
])
%>
</div></td>
<%
if
can_edit
%>
<td>
<div
class=
"text-center"
>
...
...
venshop_app/spec/requests/card_pages_spec.rb
View file @
80df58aa
...
...
@@ -278,6 +278,21 @@ describe "CardPages" do
end
describe
"calculate price"
do
let
(
:amount
)
{
1
}
before
do
visit
url_for
(
controller:
'cards'
,
action:
'checkout'
)
end
it
do
total
=
0
Product
.
all
.
each
do
|
product
|
should
have_xpath
(
"//div[@id='cart-quantity-
#{
product
.
id
}
'][text()='
#{
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
+=
product
.
price
end
should
have_selector
(
'#card-must-paid'
,
text:
ActionController
::
Base
.
helpers
.
number_with_delimiter
(
total
))
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