Skip to content

Commit

Permalink
Add test to cover weight calculation bug #3072
Browse files Browse the repository at this point in the history
  • Loading branch information
luisramos0 committed Dec 24, 2018
1 parent 38ff997 commit 37e7595
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions spec/features/consumer/shopping/cart_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,33 @@
end
end

describe "admin weight calculated fees" do
context 'order with 2 line items' do
let(:admin_fee) { create(:enterprise_fee, calculator: Calculator::Weight.new(preferred_per_kg: 1),
enterprise: order_cycle.coordinator, fee_type: 'admin') }

before do
product_fee.variants.first.update_attributes(unit_value: '2000.0')
product_tax.variants.first.update_attributes(unit_value: '5000.0')

add_enterprise_fee admin_fee

cart_service = CartService.new(order)
cart_service.populate(variants: { product_fee.variants.first.id => 3, product_tax.variants.first.id => 5 })
order.update_distribution_charge!

visit spree.cart_path
end

it 'shows the correct weight calculations' do
expect(page).to have_selector('#cart-detail')
expect(page).to have_selector '.cart-item-price', text: with_currency(2.86) # price + 1 * 2kg
expect(page).to have_selector '.cart-item-price', text: with_currency(115.0) # price + 1 * 5kg
expect(page).to have_selector '.order-total.grand-total', text: with_currency(353.58) # above * 3 items
end
end
end

describe "tax" do
before do
add_enterprise_fee enterprise_fee
Expand Down

0 comments on commit 37e7595

Please sign in to comment.