Skip to content

Commit

Permalink
add adyen specs
Browse files Browse the repository at this point in the history
  • Loading branch information
lovrocolic committed Jan 25, 2024
1 parent fd9b7f6 commit c9a2111
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions spec/services/invoices/payments/adyen_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
let(:adyen_customer) { create(:adyen_customer, customer:) }
let(:adyen_client) { instance_double(Adyen::Client) }
let(:payments_api) { Adyen::PaymentsApi.new(adyen_client, 70) }
let(:payment_links_api) { Adyen::PaymentLinksApi.new(adyen_client, 70) }
let(:payment_links_response) { generate(:adyen_payment_links_response) }
let(:checkout) { Adyen::Checkout.new(adyen_client, 70) }
let(:payments_response) { generate(:adyen_payments_response) }
let(:payment_methods_response) { generate(:adyen_payment_methods_response) }
Expand Down Expand Up @@ -339,4 +341,46 @@
end
end
end

describe '#generate_payment_url' do
before do
adyen_payment_provider
adyen_customer

allow(Adyen::Client).to receive(:new)
.and_return(adyen_client)
allow(adyen_client).to receive(:checkout)
.and_return(checkout)
allow(checkout).to receive(:payment_links_api)
.and_return(payment_links_api)
allow(payment_links_api).to receive(:payment_links)
.and_return(payment_links_response)
end

it 'generates payment url' do
adyen_service.generate_payment_url

expect(payment_links_api).to have_received(:payment_links)
end

context 'when invoice is succeeded' do
before { invoice.succeeded! }

it 'does not generate payment url' do
adyen_service.generate_payment_url

expect(payment_links_api).not_to have_received(:payment_links)
end
end

context 'when invoice is voided' do
before { invoice.voided! }

it 'does not generate payment url' do
adyen_service.generate_payment_url

expect(payment_links_api).not_to have_received(:payment_links)
end
end
end
end

0 comments on commit c9a2111

Please sign in to comment.