Skip to content

Commit

Permalink
Fix loading Stripe invoices
Browse files Browse the repository at this point in the history
Broken since the recent refactoring. Need to now call `id` on the Stripe
Customer object and pass this into the list invoices API call.

Fixes #8465
  • Loading branch information
gbp committed Nov 22, 2024
1 parent f3693d5 commit d42918a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/models/alaveteli_pro/invoice_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def each(&block)
def invoices
return [] unless @customer

@invoices ||= Stripe::Invoice.list(customer: @customer)
@invoices ||= Stripe::Invoice.list(customer: @customer.id)
end
end
end
12 changes: 6 additions & 6 deletions spec/models/alaveteli_pro/invoice_collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

RSpec.describe AlaveteliPro::InvoiceCollection do
let(:collection) { described_class.new(customer) }
let(:customer) { double(:customer) }
let(:customer) { double(:customer, id: 'cus_123') }

let(:open_invoice) { double(:invoice, status: 'open') }
let(:paid_invoice) { double(:invoice, status: 'paid', amount_paid: 10) }
Expand Down Expand Up @@ -39,7 +39,7 @@
let(:invoices) { Stripe::ListObject.new }

before do
allow(Stripe::Invoice).to receive(:list).with(customer: customer).
allow(Stripe::Invoice).to receive(:list).with(customer: 'cus_123').
and_return(invoices)
end

Expand All @@ -55,7 +55,7 @@

describe '#open' do
before do
allow(Stripe::Invoice).to receive(:list).with(customer: customer).
allow(Stripe::Invoice).to receive(:list).with(customer: 'cus_123').
and_return([open_invoice, paid_invoice])
end

Expand All @@ -66,7 +66,7 @@

describe '#paid' do
before do
allow(Stripe::Invoice).to receive(:list).with(customer: customer).
allow(Stripe::Invoice).to receive(:list).with(customer: 'cus_123').
and_return([open_invoice, paid_invoice])
end

Expand All @@ -88,7 +88,7 @@
let(:invoices) { Stripe::ListObject.new }

before do
allow(Stripe::Invoice).to receive(:list).with(customer: customer).
allow(Stripe::Invoice).to receive(:list).with(customer: 'cus_123').
and_return(invoices)
allow(invoices).to receive(:auto_paging_each).
and_yield(open_invoice).
Expand All @@ -106,7 +106,7 @@

context 'without Stripe invoices' do
before do
allow(Stripe::Invoice).to receive(:list).with(customer: customer).
allow(Stripe::Invoice).to receive(:list).with(customer: 'cus_123').
and_return([open_invoice, paid_invoice, open_invoice])
end

Expand Down

0 comments on commit d42918a

Please sign in to comment.