diff --git a/app/models/alaveteli_pro/invoice_collection.rb b/app/models/alaveteli_pro/invoice_collection.rb index b1f00882e3..8e60b107a3 100644 --- a/app/models/alaveteli_pro/invoice_collection.rb +++ b/app/models/alaveteli_pro/invoice_collection.rb @@ -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 diff --git a/spec/models/alaveteli_pro/invoice_collection_spec.rb b/spec/models/alaveteli_pro/invoice_collection_spec.rb index 8d5b634560..dbfe81d226 100644 --- a/spec/models/alaveteli_pro/invoice_collection_spec.rb +++ b/spec/models/alaveteli_pro/invoice_collection_spec.rb @@ -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) } @@ -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 @@ -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 @@ -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 @@ -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). @@ -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