diff --git a/spec/services/order_invoice_comparator_spec.rb b/spec/services/order_invoice_comparator_spec.rb index b6c6bd7276..3d904a0b22 100644 --- a/spec/services/order_invoice_comparator_spec.rb +++ b/spec/services/order_invoice_comparator_spec.rb @@ -4,7 +4,9 @@ require 'spec_helper' describe OrderInvoiceComparator do describe '#can_generate_new_invoice?' do - let!(:order) { create(:completed_order_with_fees) } + let!(:completed_order_with_fees) { create(:completed_order_with_fees) } + # this passes 'order' as argument to the invoice comparator + let(:order) { completed_order_with_fees } let!(:invoice_data_generator){ InvoiceDataGenerator.new(order) } let!(:invoice){ create(:invoice, @@ -35,20 +37,18 @@ describe OrderInvoiceComparator do let(:distributor) { create(:distributor_enterprise) } let!(:order_with_taxes) do create(:order_with_taxes, distributor: distributor, ship_address: create(:address), - product_price: 110, tax_rate_amount: 0.1, included_in_price: false, + product_price: 110, tax_rate_amount: 0.1, + included_in_price: false, tax_rate_name: "Tax 1").tap do |order| order.create_tax_charge! order.update_shipping_fees! end end + let!(:order) { order_with_taxes } it "returns returns true" do - expect(order_with_taxes.additional_tax_total).to eq 0.11e2 Spree::TaxRate.first.update!(amount: 0.15) order_with_taxes.create_tax_charge! && order_with_taxes.save - - expect(order_with_taxes.additional_tax_total).to eq 0.165e2 - expect(subject).to be true end end @@ -64,26 +64,20 @@ describe OrderInvoiceComparator do order.update_shipping_fees! end end + let!(:order) { order_with_taxes } it "returns returns true" do - expect(order_with_taxes.included_tax_total).to eq 0.1e2 Spree::TaxRate.first.update!(amount: 0.15) order_with_taxes.create_tax_charge! && order_with_taxes.save - - expect(order_with_taxes.included_tax_total).to eq 0.1435e2 - expect(subject).to be true end end context "shipping method changes" do let(:shipping_method) { create(:shipping_method) } - let!(:order_ready_to_ship) { - create(:order_ready_to_ship) - } + let!(:order) { completed_order_with_fees } it "returns returns true" do Spree::ShippingRate.first.update(shipping_method_id: shipping_method.id) - order_ready_to_ship.update_shipping_fees! && order_ready_to_ship.save expect(subject).to be true end end