Skip to content

Commit

Permalink
test the invoice number on the printed version
Browse files Browse the repository at this point in the history
  • Loading branch information
abdellani committed Nov 13, 2023
1 parent 6ad7d53 commit 5723644
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion spec/system/admin/invoice_print_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

let(:order) do
create(:order_with_totals_and_distribution, user:, distributor:,
completed_at: 1.day.ago,
order_cycle:, state: 'complete',
payment_state: 'balance_due')
end
Expand Down Expand Up @@ -462,12 +463,44 @@
end
context "when invoice feature is enabled" do
before do
Flipper.enable(:invoice)
Flipper.enable(:invoices)
end
it_behaves_like "contains right Payment Description at Checkout information"
it_behaves_like "Check display on each invoice: legacy and alternative", false
it_behaves_like "Check display on each invoice: legacy and alternative", true
it_behaves_like "order with tax"

context "Order doesn't have previous invoices" do
it "should display the invoice number" do
login_as_admin
visit spree.print_admin_order_path(order, params: {})

convert_pdf_to_page
expect(page).to have_content "#{order.distributor_id}-#{order.invoices.first.number}"
end
end

context "Order has previous invoices" do
before do
OrderInvoiceGenerator.new(order).generate_or_update_latest_invoice
first_line_item = order.line_items.first
order.line_items.first.update(quantity: first_line_item.quantity + 1)
end

it "should display the invoice number along with the latest invoice number" do
login_as_admin
visit spree.print_admin_order_path(order, params: {})

expect(order.invoices.count).to eq(2)

new_invoice_number = "#{order.distributor_id}-#{order.invoices.first.number}"
canceled_invoice_number = "#{order.distributor_id}-#{order.invoices.last.number}"

convert_pdf_to_page
expect(page).to have_content "#{new_invoice_number} cancels and replaces invoice #{
canceled_invoice_number}"
end
end
end
end

Expand Down

0 comments on commit 5723644

Please sign in to comment.