mirror of
https://github.com/internetee/registry.git
synced 2025-07-30 14:36:22 +02:00
updated tests
This commit is contained in:
parent
998827a01d
commit
3242fb1da0
5 changed files with 122 additions and 20 deletions
|
@ -123,16 +123,11 @@ class InvoiceTest < ActiveSupport::TestCase
|
|||
transaction.sum = 250
|
||||
|
||||
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: {})
|
||||
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator")
|
||||
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
|
||||
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator")
|
||||
.to_return(status: 200, body: "", headers: {})
|
||||
|
||||
invoice = Invoice.create_from_transaction!(transaction)
|
||||
assert_equal 250, invoice.total
|
||||
|
@ -171,6 +166,18 @@ class InvoiceTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_emails_invoice_after_creating_topup_invoice
|
||||
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||
with(
|
||||
body: "{\"transaction_amount\":\"250.0\",\"order_reference\":4,\"customer_name\":\"Best Names\",\"customer_email\":\"info@bestnames.test\",\"custom_field_1\":\"Direct top-up via bank transfer\",\"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: "", headers: {})
|
||||
|
||||
registrar = registrars(:bestnames)
|
||||
transaction = bank_transactions(:one).dup
|
||||
transaction.reference_no = registrar.reference_no
|
||||
|
|
|
@ -144,6 +144,18 @@ class RegistrarTest < ActiveJob::TestCase
|
|||
end
|
||||
|
||||
def test_issues_new_invoice
|
||||
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\":null,\"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: "", headers: {})
|
||||
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
with(
|
||||
|
@ -166,6 +178,18 @@ class RegistrarTest < ActiveJob::TestCase
|
|||
end
|
||||
|
||||
def test_issues_e_invoice_along_with_invoice
|
||||
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\":null,\"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: "", headers: {})
|
||||
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
with(
|
||||
|
|
|
@ -55,17 +55,13 @@ class AdminAreaBankStatementTest < ApplicationSystemTestCase
|
|||
|
||||
def test_can_bind_statement_transactions
|
||||
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: {})
|
||||
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator")
|
||||
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
registrar = registrars(:bestnames)
|
||||
|
||||
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator")
|
||||
.to_return(status: 200, body: "", headers: {})
|
||||
|
||||
registrar.issue_prepayment_invoice(500)
|
||||
invoice = registrar.invoices.last
|
||||
|
||||
|
|
|
@ -88,6 +88,19 @@ class ProcessPaymentsTaskTest < ActiveJob::TestCase
|
|||
'User-Agent'=>'Ruby'
|
||||
}).
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
|
||||
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||
with(
|
||||
body: "{\"transaction_amount\":\"0.1\",\"order_reference\":5,\"customer_name\":\"Best Names\",\"customer_email\":\"info@bestnames.test\",\"custom_field_1\":\"Direct top-up via bank transfer\",\"custom_field_2\":\"registry\",\"invoice_number\":5}",
|
||||
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: "", headers: {})
|
||||
|
||||
assert_not @invoice.paid?
|
||||
|
||||
@account_activity.update(activity_type: "add_credit", bank_transaction: nil, created_at: Time.zone.today - 3.days, creator_str: 'AdminUser')
|
||||
|
@ -166,6 +179,19 @@ class ProcessPaymentsTaskTest < ActiveJob::TestCase
|
|||
'User-Agent'=>'Ruby'
|
||||
}).
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
|
||||
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||
with(
|
||||
body: "{\"transaction_amount\":\"0.1\",\"order_reference\":5,\"customer_name\":\"Best Names\",\"customer_email\":\"info@bestnames.test\",\"custom_field_1\":\"Direct top-up via bank transfer\",\"custom_field_2\":\"registry\",\"invoice_number\":5}",
|
||||
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: "", headers: {})
|
||||
|
||||
registrar = registrars(:bestnames)
|
||||
|
||||
assert_changes -> { registrar.accounts.first.balance } do
|
||||
|
@ -196,6 +222,19 @@ class ProcessPaymentsTaskTest < ActiveJob::TestCase
|
|||
'User-Agent'=>'Ruby'
|
||||
}).
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
|
||||
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||
with(
|
||||
body: "{\"transaction_amount\":\"0.1\",\"order_reference\":5,\"customer_name\":\"Best Names\",\"customer_email\":\"info@bestnames.test\",\"custom_field_1\":\"Direct top-up via bank transfer\",\"custom_field_2\":\"registry\",\"invoice_number\":5}",
|
||||
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: "", headers: {})
|
||||
|
||||
registrar = registrars(:bestnames)
|
||||
@invoice.payment_orders.destroy_all
|
||||
@invoice.destroy
|
||||
|
|
|
@ -20,6 +20,18 @@ class ReloadBalanceTaskTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_issues_invoice_when_auto_reload_is_enabled_and_threshold_reached
|
||||
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\":null,\"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: "", headers: {})
|
||||
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
with(
|
||||
|
@ -61,6 +73,18 @@ class ReloadBalanceTaskTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_marks_registrar_as_pending_balance_reload
|
||||
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\":null,\"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: "", headers: {})
|
||||
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
with(
|
||||
|
@ -81,6 +105,18 @@ class ReloadBalanceTaskTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_output
|
||||
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\":null,\"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: "", headers: {})
|
||||
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
with(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue