mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-11 22:24:21 +01:00
24 lines
774 B
Ruby
24 lines
774 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'test_helper'
|
|
|
|
class Cart::UpdateTotalServiceTest < ActiveSupport::TestCase
|
|
setup do
|
|
@panneaux = Product.find_by(slug: 'panneaux-de-mdf')
|
|
end
|
|
|
|
test 'total equal to product amount multiplied quantity' do
|
|
order = Order.new
|
|
order.order_items.push OrderItem.new(orderable: @panneaux, amount: @panneaux.amount, quantity: 10)
|
|
cart = Cart::UpdateTotalService.new.call(order)
|
|
assert_equal cart.total, @panneaux.amount * 10
|
|
end
|
|
|
|
test 'total equal to zero if product offered' do
|
|
order = Order.new
|
|
order.order_items.push OrderItem.new(orderable: @panneaux, amount: @panneaux.amount, quantity: 10, is_offered: true)
|
|
cart = Cart::UpdateTotalService.new.call(order)
|
|
assert_equal cart.total, 0
|
|
end
|
|
end
|