Skip to content

Commit

Permalink
adds test coverage related to customer balance, openfoodfoundation#6366
Browse files Browse the repository at this point in the history
  • Loading branch information
filipefurtad0 committed Mar 3, 2021
1 parent 03e969f commit 1e4ec01
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions spec/models/spree/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1357,4 +1357,27 @@ def advance_to_delivery_state(order)
end
end
end

describe "editing a complete order, with two line items" do
let!(:payment_method) { create(:payment_method) }
let!(:shipping_method) { create(:shipping_method) }
let(:order) { create(:order_ready_to_ship, line_items_count: 2) }
let(:item_num) { order.line_items.length }

context "updates the customer balance correctly" do
it "when an item is removed" do
order.line_items.first.destroy
order.update!
expect(item_num).to eq 1
expect(order.payment_state).to eq('credit_owed')
end

it "when the quantity of an item is increased" do
expect(item_num).to eq 2
order.line_items.second.update_attribute(:quantity, 2)
order.update!
expect(order.payment_state).to eq('balance_due')
end
end
end
end

0 comments on commit 1e4ec01

Please sign in to comment.