Commit ef76ace2 by vulehuan

rspec: card - after update quantity, we also check the total cost

parent 5fd64555
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
<td colspan="3"> <td colspan="3">
</td> </td>
<td colspan="<%= can_edit ? 3 : 2 %>"> <td colspan="<%= can_edit ? 3 : 2 %>">
<b><%= number_with_delimiter(total) %></b> <div id="card-must-paid"><b><%= number_with_delimiter(total) %></b></div>
</td> </td>
</tr> </tr>
<% if can_edit %> <% if can_edit %>
......
...@@ -68,6 +68,14 @@ describe "CardPages" do ...@@ -68,6 +68,14 @@ describe "CardPages" do
page.should have_xpath("//input[@id='cart-quantity-#{product.id}'][@value='#{amount}']") 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-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)) page.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|
total += obj.price
end
total += (amount - 1) * product.price
page.should have_selector('#card-must-paid', text: ActionController::Base.helpers.number_with_delimiter(total))
end end
end end
......
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