added generator reference number which comes from billing system

This commit is contained in:
olegphenomenon 2022-01-26 15:36:42 +02:00
parent 9b6b8a5e2f
commit 84669297b5
8 changed files with 86 additions and 26 deletions

View file

@ -14,6 +14,18 @@ class AdminRegistrarsSystemTest < ApplicationSystemTestCase
end
def test_creates_new_registrar
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/reference_number_generator").
with(
body: "{\"initiator\":\"registry\"}",
headers: {
'Accept'=>'Bearer WA9UvDmzR9UcE5rLqpWravPQtdS8eDMAIynzGdSOTw==--9ZShwwij3qmLeuMJ--NE96w2PnfpfyIuuNzDJTGw==',
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
'Authorization'=>'Bearer foobar',
'Content-Type'=>'application/json',
'User-Agent'=>'Ruby'
}).
to_return(status: 200, body: "{\"reference_number\":\"12332\"}", headers: {})
assert_nil Registrar.find_by(name: 'Acme Ltd')
visit admin_registrars_path

View file

@ -12,6 +12,18 @@ class AddDepositsTest < ApplicationSystemTestCase
def test_should_send_request_for_creating_invoice_to_eis_system
invoice_n = Invoice.order(number: :desc).last.number
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
with(
body: "{\"transaction_amount\":\"120.0\",\"order_reference\":4,\"customer_name\":\"Best Names\",\"customer_email\":\"info@bestnames.test\",\"custom_field_1\":\"\",\"custom_field_2\":\"registry\",\"invoice_number\":4}",
headers: {
'Accept'=>'Bearer WA9UvDmzR9UcE5rLqpWravPQtdS8eDMAIynzGdSOTw==--9ZShwwij3qmLeuMJ--NE96w2PnfpfyIuuNzDJTGw==',
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
'Authorization'=>'Bearer foobar',
'Content-Type'=>'application/json',
'User-Agent'=>'Ruby'
}).
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
with(
headers: {
@ -22,8 +34,8 @@ class AddDepositsTest < ApplicationSystemTestCase
'User-Agent'=>'Ruby'
}).
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
eis_response = OpenStruct.new(body: "{\"payment_link\":\"http://link.test\"}")
Spy.on_instance_method(EisBilling::AddDeposits, :send_invoice).and_return(eis_response)
# eis_response = OpenStruct.new(body: "{\"payment_link\":\"http://link.test\"}")
# Spy.on_instance_method(EisBilling::AddDeposits, :send_invoice).and_return(eis_response)
visit new_registrar_deposit_url
fill_in 'Amount', with: '100.0'

View file

@ -43,26 +43,6 @@ class RegistrarAreaInvoicesTest < ApplicationSystemTestCase
assert_text 'Invoice has been sent'
end
def test_if_invoice_unpaid_should_be_present_everypay_link
eis_response = OpenStruct.new(body: "{\"payment_link\":\"http://link.test\"}")
Spy.on_instance_method(EisBilling::AddDeposits, :send_invoice).and_return(eis_response)
invoice_n = Invoice.order(number: :desc).last.number
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
with(
headers: {
'Accept'=>'Bearer WA9UvDmzR9UcE5rLqpWravPQtdS8eDMAIynzGdSOTw==--9ZShwwij3qmLeuMJ--NE96w2PnfpfyIuuNzDJTGw==',
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
'Authorization'=>'Bearer foobar',
'Content-Type'=>'application/json',
'User-Agent'=>'Ruby'
}).
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
invoice = invoices(:unpaid)
visit registrar_invoice_url(invoice)
assert_text 'Everypay link'
end
def test_if_invoice_unpaid_and_not_generated_link_comes_then_should_render_no_everypay_link
invoice = invoices(:unpaid)
visit registrar_invoice_url(invoice)