Commit 80df58aa by vulehuan

rspec: card - step 2: calculate price

parent e11b2ec7
...@@ -31,10 +31,10 @@ ...@@ -31,10 +31,10 @@
<% if can_edit %> <% if can_edit %>
<td><input id="cart-quantity-<%= card_item[:product_id] %>" type="text" class="form-control txt-quantity" value="<%= card_item[:quantity] %>" /></td> <td><input id="cart-quantity-<%= card_item[:product_id] %>" type="text" class="form-control txt-quantity" value="<%= card_item[:quantity] %>" /></td>
<% else %> <% 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 %> <% 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" id="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-total-price-<%= card_item[:product_id] %>"><%= number_with_delimiter(product.price * card_item[:quantity]) %></div></td>
<% if can_edit %> <% if can_edit %>
<td> <td>
<div class="text-center"> <div class="text-center">
......
...@@ -278,6 +278,21 @@ describe "CardPages" do ...@@ -278,6 +278,21 @@ describe "CardPages" do
end end
describe "calculate price" do 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
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