mirror of
https://github.com/internetee/registry.git
synced 2025-07-30 06:26:15 +02:00
Merge pull request #2433 from internetee/remove-feature-toggle
remove eis-billing feature toggle
This commit is contained in:
commit
f77883b266
29 changed files with 459 additions and 583 deletions
|
@ -24,30 +24,28 @@ class AdminAreaInvoicesIntegrationTest < ApplicationIntegrationTest
|
|||
end
|
||||
|
||||
def test_create_new_invoice
|
||||
if Feature.billing_system_integrated?
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||
|
||||
stub_request(:post, "https://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, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
|
||||
visit new_admin_invoice_path
|
||||
visit new_admin_invoice_path
|
||||
|
||||
assert_text 'Create new invoice'
|
||||
select 'Best Names', from: 'deposit_registrar_id', match: :first
|
||||
fill_in 'Amount', with: '1000'
|
||||
click_on 'Save'
|
||||
assert_text 'Create new invoice'
|
||||
select 'Best Names', from: 'deposit_registrar_id', match: :first
|
||||
fill_in 'Amount', with: '1000'
|
||||
click_on 'Save'
|
||||
|
||||
assert_equal page.status_code, 200
|
||||
end
|
||||
assert_equal page.status_code, 200
|
||||
end
|
||||
|
||||
def test_visit_list_of_invoices_pages
|
||||
|
|
|
@ -10,34 +10,30 @@ class DirectoResponseTest < ApplicationIntegrationTest
|
|||
end
|
||||
|
||||
def test_should_created_directo_instance
|
||||
if Feature.billing_system_integrated?
|
||||
directo_response_from_billing = {
|
||||
response: @response_xml,
|
||||
month: true
|
||||
}
|
||||
directo_response_from_billing = {
|
||||
response: @response_xml,
|
||||
month: true
|
||||
}
|
||||
|
||||
assert_difference 'Directo.count', 1 do
|
||||
put eis_billing_directo_response_path, params: JSON.parse(directo_response_from_billing.to_json),
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
assert_difference 'Directo.count', 1 do
|
||||
put eis_billing_directo_response_path, params: JSON.parse(directo_response_from_billing.to_json),
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
end
|
||||
|
||||
def test_should_update_related_invoice
|
||||
if Feature.billing_system_integrated?
|
||||
directo_response_from_billing = {
|
||||
response: @response_xml
|
||||
}
|
||||
directo_response_from_billing = {
|
||||
response: @response_xml
|
||||
}
|
||||
|
||||
refute @invoice.in_directo
|
||||
refute @invoice.in_directo
|
||||
|
||||
assert_difference 'Directo.count', 1 do
|
||||
put eis_billing_directo_response_path, params: JSON.parse(directo_response_from_billing.to_json),
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
|
||||
@invoice.reload
|
||||
assert @invoice.in_directo
|
||||
assert_difference 'Directo.count', 1 do
|
||||
put eis_billing_directo_response_path, params: JSON.parse(directo_response_from_billing.to_json),
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
|
||||
@invoice.reload
|
||||
assert @invoice.in_directo
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,8 +8,6 @@ class LhvConnectTransactionsIntegrationTest < ApplicationIntegrationTest
|
|||
end
|
||||
|
||||
def test_should_saved_transaction_data
|
||||
return unless Feature.billing_system_integrated?
|
||||
|
||||
test_transaction_1 = OpenStruct.new(amount: 0.1,
|
||||
currency: 'EUR',
|
||||
date: Time.zone.today,
|
||||
|
|
|
@ -12,6 +12,18 @@ class ReppV1InvoicesAddCreditTest < ActionDispatch::IntegrationTest
|
|||
eis_response = OpenStruct.new(body: '{"everypay_link":"https://link.test"}')
|
||||
Spy.on_instance_method(EisBilling::AddDeposits, :send_invoice).and_return(eis_response)
|
||||
Spy.on_instance_method(EisBilling::BaseController, :authorized).and_return(true)
|
||||
|
||||
invoice = Invoice.last
|
||||
msg = {
|
||||
invoice_number: invoice.number + 3
|
||||
}
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator")
|
||||
.to_return(status: 200, body: msg.to_json, headers: {})
|
||||
|
||||
msg2 = {
|
||||
message: 'success'
|
||||
}
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").to_return(status: 200, body: msg2.to_json, headers: {})
|
||||
end
|
||||
|
||||
teardown do
|
||||
|
@ -28,13 +40,11 @@ class ReppV1InvoicesAddCreditTest < ActionDispatch::IntegrationTest
|
|||
Setting.registry_vat_prc = 0.1
|
||||
ENV['billing_system_integrated'] = 'true'
|
||||
|
||||
if Feature.billing_system_integrated?
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, 'https://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, 'https://eis_billing_system:3000/api/v1/e_invoice/e_invoice')
|
||||
.to_return(status: 200, body: '', headers: {})
|
||||
end
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, 'https://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, 'https://eis_billing_system:3000/api/v1/e_invoice/e_invoice')
|
||||
.to_return(status: 200, body: '', headers: {})
|
||||
|
||||
post '/repp/v1/invoices/add_credit', headers: @auth_headers,
|
||||
params: request_body
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require "test_helper"
|
||||
|
||||
class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
||||
class DirectoInvoiceForwardLegacyJobTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@invoice = invoices(:one)
|
||||
@user = registrars(:bestnames)
|
||||
|
@ -38,7 +38,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
|||
end.to_return(status: 200, body: response)
|
||||
|
||||
assert_nothing_raised do
|
||||
DirectoInvoiceForwardJob.perform_now(monthly: false, dry: false)
|
||||
DirectoInvoiceForwardLegacyJob.perform_now(monthly: false, dry: false)
|
||||
end
|
||||
|
||||
assert_not_empty @invoice.directo_records.first.request
|
||||
|
@ -52,7 +52,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
|||
Setting.directo_monthly_number_max = 30_991
|
||||
|
||||
assert_raises 'RuntimeError' do
|
||||
DirectoInvoiceForwardJob.perform_now(monthly: true, dry: false)
|
||||
DirectoInvoiceForwardLegacyJob.perform_now(monthly: true, dry: false)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -78,7 +78,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
|||
end.to_return(status: 200, body: response)
|
||||
|
||||
assert_difference 'Setting.directo_monthly_number_last' do
|
||||
DirectoInvoiceForwardJob.perform_now(monthly: true, dry: false)
|
||||
DirectoInvoiceForwardLegacyJob.perform_now(monthly: true, dry: false)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -103,7 +103,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
|||
end.to_return(status: 200, body: response)
|
||||
|
||||
assert_difference 'Setting.directo_monthly_number_last' do
|
||||
DirectoInvoiceForwardJob.perform_now(monthly: true, dry: false)
|
||||
DirectoInvoiceForwardLegacyJob.perform_now(monthly: true, dry: false)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -126,7 +126,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
|||
end.to_return(status: 200, body: response)
|
||||
|
||||
assert_difference 'Setting.directo_monthly_number_last' do
|
||||
DirectoInvoiceForwardJob.perform_now(monthly: true, dry: false)
|
||||
DirectoInvoiceForwardLegacyJob.perform_now(monthly: true, dry: false)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -148,7 +148,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
|||
end.to_return(status: 200, body: response)
|
||||
|
||||
assert_difference 'Setting.directo_monthly_number_last' do
|
||||
DirectoInvoiceForwardJob.perform_now(monthly: true, dry: false)
|
||||
DirectoInvoiceForwardLegacyJob.perform_now(monthly: true, dry: false)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -186,7 +186,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
|||
(body.include? 'StartDate') && (body.include? 'EndDate') && (body.include? 'goodnames')
|
||||
end.to_return(status: 200, body: response)
|
||||
|
||||
DirectoInvoiceForwardJob.perform_now(monthly: true, dry: false)
|
||||
DirectoInvoiceForwardLegacyJob.perform_now(monthly: true, dry: false)
|
||||
|
||||
assert_requested first_registrar_stub
|
||||
assert_requested second_registrar_stub
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
require 'test_helper'
|
||||
|
||||
class SendEInvoiceJobTest < ActiveJob::TestCase
|
||||
class SendEInvoiceLegacyJobTest < ActiveJob::TestCase
|
||||
|
||||
def teardown
|
||||
EInvoice.provider = EInvoice::Providers::TestProvider.new
|
||||
EInvoice::Providers::TestProvider.deliveries.clear
|
||||
|
||||
msg = { message: 'success' }
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice")
|
||||
.to_return(status: 200, body: msg.to_json, headers: {})
|
||||
end
|
||||
|
||||
def test_if_invoice_is_sent
|
||||
|
@ -15,7 +19,7 @@ class SendEInvoiceJobTest < ActiveJob::TestCase
|
|||
|
||||
assert_nothing_raised do
|
||||
perform_enqueued_jobs do
|
||||
SendEInvoiceJob.perform_now(@invoice.id, payable: true)
|
||||
SendEInvoiceLegacyJob.perform_now(@invoice.id, payable: true)
|
||||
end
|
||||
end
|
||||
@invoice.reload
|
|
@ -10,6 +10,10 @@ class SendMonthlyInvoicesJobTest < ActiveSupport::TestCase
|
|||
ActionMailer::Base.deliveries.clear
|
||||
EInvoice.provider = EInvoice::Providers::TestProvider.new
|
||||
EInvoice::Providers::TestProvider.deliveries.clear
|
||||
|
||||
response = { message: 'sucess' }
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice")
|
||||
.to_return(status: 200, body: response.to_json, headers: {})
|
||||
end
|
||||
|
||||
def teardown
|
||||
|
@ -107,7 +111,7 @@ class SendMonthlyInvoicesJobTest < ActiveSupport::TestCase
|
|||
assert_equal 'Invoice no. 309902 (monthly invoice)', email.subject
|
||||
assert email.attachments['invoice-309902.pdf']
|
||||
|
||||
assert_equal 1, EInvoice::Providers::TestProvider.deliveries.count
|
||||
# assert_equal 1, EInvoice::Providers::TestProvider.deliveries.count
|
||||
end
|
||||
|
||||
def test_monthly_summary_is_delivered_in_estonian
|
||||
|
@ -150,7 +154,7 @@ class SendMonthlyInvoicesJobTest < ActiveSupport::TestCase
|
|||
assert_equal 'Invoice no. 309902 (monthly invoice)', email.subject
|
||||
assert email.attachments['invoice-309902.pdf']
|
||||
|
||||
assert_equal 1, EInvoice::Providers::TestProvider.deliveries.count
|
||||
# assert_equal 1, EInvoice::Providers::TestProvider.deliveries.count
|
||||
end
|
||||
|
||||
def test_multi_year_purchases_have_duration_assigned
|
||||
|
|
|
@ -22,8 +22,6 @@ class BankTransactionTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_binds_if_this_sum_invoice_already_present
|
||||
return unless Feature.billing_system_integrated?
|
||||
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator')
|
||||
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
|
@ -51,8 +49,6 @@ class BankTransactionTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_binds_if_this_sum_cancelled_invoice_already_present
|
||||
return unless Feature.billing_system_integrated?
|
||||
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator')
|
||||
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
|
@ -76,8 +72,6 @@ class BankTransactionTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_marks_the_first_one_as_paid_if_same_sum
|
||||
return unless Feature.billing_system_integrated?
|
||||
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator')
|
||||
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
|
|
|
@ -7,12 +7,10 @@ class ReferenceNoTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_generated_reference_number_conforms_to_format
|
||||
if Feature.billing_system_integrated?
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/reference_number_generator")
|
||||
.to_return(status: 200, body: "{\"reference_number\":\"12332\"}", headers: {})
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/reference_number_generator")
|
||||
.to_return(status: 200, body: "{\"reference_number\":\"12332\"}", headers: {})
|
||||
|
||||
reference_no = Billing::ReferenceNo.generate
|
||||
assert_match Billing::ReferenceNo::REGEXP, reference_no
|
||||
end
|
||||
reference_no = Billing::ReferenceNo.generate
|
||||
assert_match Billing::ReferenceNo::REGEXP, reference_no
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,53 +1,4 @@
|
|||
require 'test_helper'
|
||||
|
||||
class FeatureTest < ActiveSupport::TestCase
|
||||
# setup do
|
||||
# @domain = domains(:shop)
|
||||
# @domain.apply_registry_lock(extensions_prohibited: false)
|
||||
# end
|
||||
#
|
||||
# def test_if_obj_and_extensions_prohibited_enabled
|
||||
# ENV['obj_and_extensions_prohibited'] = 'true'
|
||||
#
|
||||
# assert Feature.obj_and_extensions_statuses_enabled?
|
||||
#
|
||||
# statuses = DomainStatus.admin_statuses
|
||||
# assert statuses.include? DomainStatus::SERVER_OBJ_UPDATE_PROHIBITED
|
||||
# end
|
||||
#
|
||||
# def test_if_obj_and_extensions_prohibited_is_nil
|
||||
# ENV['obj_and_extensions_prohibited'] = nil
|
||||
#
|
||||
# assert_not Feature.obj_and_extensions_statuses_enabled?
|
||||
#
|
||||
# statuses = DomainStatus.admin_statuses
|
||||
# assert_not statuses.include? DomainStatus::SERVER_OBJ_UPDATE_PROHIBITED
|
||||
# end
|
||||
#
|
||||
# def test_if_obj_and_extensions_prohibited_is_false
|
||||
# ENV['obj_and_extensions_prohibited'] = 'false'
|
||||
#
|
||||
# assert_not Feature.obj_and_extensions_statuses_enabled?
|
||||
#
|
||||
# statuses = DomainStatus.admin_statuses
|
||||
# assert_not statuses.include? DomainStatus::SERVER_OBJ_UPDATE_PROHIBITED
|
||||
# end
|
||||
#
|
||||
# def test_if_enable_lock_domain_with_new_statuses_is_nil
|
||||
# ENV['enable_lock_domain_with_new_statuses'] = nil
|
||||
#
|
||||
# assert_not Feature.enable_lock_domain_with_new_statuses?
|
||||
#
|
||||
# assert_equal @domain.statuses, ["serverObjUpdateProhibited", "serverDeleteProhibited", "serverTransferProhibited"]
|
||||
# assert @domain.locked_by_registrant?
|
||||
# end
|
||||
#
|
||||
# def test_if_enable_lock_domain_with_new_statuses_is_false
|
||||
# ENV['enable_lock_domain_with_new_statuses'] = 'false'
|
||||
#
|
||||
# assert_not Feature.enable_lock_domain_with_new_statuses?
|
||||
#
|
||||
# assert_equal @domain.statuses, ["serverObjUpdateProhibited", "serverDeleteProhibited", "serverTransferProhibited"]
|
||||
# assert @domain.locked_by_registrant?
|
||||
# end
|
||||
end
|
||||
|
|
|
@ -118,69 +118,65 @@ class InvoiceTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_creates_invoice_with_bank_transaction_total
|
||||
if Feature.billing_system_integrated?
|
||||
registrar = registrars(:bestnames)
|
||||
transaction = bank_transactions(:one).dup
|
||||
transaction.reference_no = registrar.reference_no
|
||||
transaction.sum = 250
|
||||
registrar = registrars(:bestnames)
|
||||
transaction = bank_transactions(:one).dup
|
||||
transaction.reference_no = registrar.reference_no
|
||||
transaction.sum = 250
|
||||
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator")
|
||||
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://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, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator")
|
||||
.to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator")
|
||||
.to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
|
||||
invoice = Invoice.create_from_transaction!(transaction)
|
||||
assert_equal 250, invoice.total
|
||||
invoice = Invoice.create_from_transaction!(transaction)
|
||||
assert_equal 250, invoice.total
|
||||
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 4}\"}", headers: {})
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 4}\"}", headers: {})
|
||||
|
||||
transaction.sum = 146.88
|
||||
invoice = Invoice.create_from_transaction!(transaction)
|
||||
assert_equal 146.88, invoice.total
|
||||
transaction.sum = 146.88
|
||||
invoice = Invoice.create_from_transaction!(transaction)
|
||||
assert_equal 146.88, invoice.total
|
||||
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 5}\"}", headers: {})
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 5}\"}", headers: {})
|
||||
|
||||
transaction.sum = 0.99
|
||||
invoice = Invoice.create_from_transaction!(transaction)
|
||||
assert_equal 0.99, invoice.total
|
||||
end
|
||||
transaction.sum = 0.99
|
||||
invoice = Invoice.create_from_transaction!(transaction)
|
||||
assert_equal 0.99, invoice.total
|
||||
end
|
||||
|
||||
def test_emails_invoice_after_creating_topup_invoice
|
||||
if Feature.billing_system_integrated?
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
|
||||
registrar = registrars(:bestnames)
|
||||
transaction = bank_transactions(:one).dup
|
||||
transaction.reference_no = registrar.reference_no
|
||||
transaction.sum = 250
|
||||
registrar = registrars(:bestnames)
|
||||
transaction = bank_transactions(:one).dup
|
||||
transaction.reference_no = registrar.reference_no
|
||||
transaction.sum = 250
|
||||
|
||||
response = OpenStruct.new(body: "{\"invoice_number\":\"#{invoice_n + 3}\"}")
|
||||
Spy.on(EisBilling::GetInvoiceNumber, :send_invoice).and_return(response)
|
||||
response = OpenStruct.new(body: "{\"invoice_number\":\"#{invoice_n + 3}\"}")
|
||||
Spy.on(EisBilling::GetInvoiceNumber, :send_invoice).and_return(response)
|
||||
|
||||
assert_emails 1 do
|
||||
Invoice.create_from_transaction!(transaction)
|
||||
end
|
||||
assert_emails 1 do
|
||||
Invoice.create_from_transaction!(transaction)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -145,55 +145,47 @@ class RegistrarTest < ActiveJob::TestCase
|
|||
end
|
||||
|
||||
def test_issues_new_invoice
|
||||
if Feature.billing_system_integrated?
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
Setting.days_to_keep_invoices_active = 10
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
Setting.days_to_keep_invoices_active = 10
|
||||
|
||||
invoice = @registrar.issue_prepayment_invoice(100)
|
||||
invoice = @registrar.issue_prepayment_invoice(100)
|
||||
|
||||
assert_equal Date.parse('2010-07-05'), invoice.issue_date
|
||||
assert_equal Date.parse('2010-07-15'), invoice.due_date
|
||||
end
|
||||
assert_equal Date.parse('2010-07-05'), invoice.issue_date
|
||||
assert_equal Date.parse('2010-07-15'), invoice.due_date
|
||||
end
|
||||
|
||||
def test_issues_e_invoice_along_with_invoice
|
||||
if Feature.billing_system_integrated?
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
end
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
|
||||
EInvoice::Providers::TestProvider.deliveries.clear
|
||||
|
||||
perform_enqueued_jobs do
|
||||
@registrar.issue_prepayment_invoice(100)
|
||||
end
|
||||
|
||||
unless Feature.billing_system_integrated?
|
||||
assert_equal 1, EInvoice::Providers::TestProvider.deliveries.count
|
||||
end
|
||||
end
|
||||
|
||||
def test_invalid_without_address_street
|
||||
|
|
|
@ -58,39 +58,37 @@ class AdminAreaBankStatementTest < ApplicationSystemTestCase
|
|||
end
|
||||
|
||||
def test_can_bind_statement_transactions
|
||||
if Feature.billing_system_integrated?
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://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)
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://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, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator")
|
||||
.to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator")
|
||||
.to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response")
|
||||
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response")
|
||||
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice")
|
||||
.to_return(status: 200, body: "", headers: {})
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice")
|
||||
.to_return(status: 200, body: "", headers: {})
|
||||
|
||||
registrar.issue_prepayment_invoice(500)
|
||||
invoice = registrar.invoices.last
|
||||
registrar.issue_prepayment_invoice(500)
|
||||
invoice = registrar.invoices.last
|
||||
|
||||
create_bank_statement
|
||||
click_link_or_button 'Add'
|
||||
assert_text 'Create bank transaction'
|
||||
create_bank_statement
|
||||
click_link_or_button 'Add'
|
||||
assert_text 'Create bank transaction'
|
||||
|
||||
fill_in 'Description', with: "Invoice with id #{invoice.number}"
|
||||
fill_in 'Reference number', with: invoice.reference_no
|
||||
fill_in 'Sum', with: invoice.total
|
||||
fill_in 'Paid at', with: Time.zone.today.to_s
|
||||
click_link_or_button 'Save'
|
||||
fill_in 'Description', with: "Invoice with id #{invoice.number}"
|
||||
fill_in 'Reference number', with: invoice.reference_no
|
||||
fill_in 'Sum', with: invoice.total
|
||||
fill_in 'Paid at', with: Time.zone.today.to_s
|
||||
click_link_or_button 'Save'
|
||||
|
||||
click_link_or_button 'Back to bank statement'
|
||||
click_link_or_button 'Bind invoices'
|
||||
click_link_or_button 'Back to bank statement'
|
||||
click_link_or_button 'Bind invoices'
|
||||
|
||||
assert_text 'Invoices were fully binded'
|
||||
end
|
||||
assert_text 'Invoices were fully binded'
|
||||
end
|
||||
|
||||
def create_bank_statement
|
||||
|
|
|
@ -14,30 +14,28 @@ class AdminRegistrarsSystemTest < ApplicationSystemTestCase
|
|||
end
|
||||
|
||||
def test_creates_new_registrar
|
||||
if Feature.billing_system_integrated?
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/reference_number_generator").
|
||||
to_return(status: 200, body: "{\"reference_number\":\"12332\"}", headers: {})
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/reference_number_generator").
|
||||
to_return(status: 200, body: "{\"reference_number\":\"12332\"}", headers: {})
|
||||
|
||||
assert_nil Registrar.find_by(name: 'Acme Ltd')
|
||||
assert_nil Registrar.find_by(name: 'Acme Ltd')
|
||||
|
||||
visit admin_registrars_path
|
||||
click_on 'New registrar'
|
||||
visit admin_registrars_path
|
||||
click_on 'New registrar'
|
||||
|
||||
fill_in 'Name', with: 'Acme Ltd'
|
||||
fill_in 'Reg no', with: '1234'
|
||||
fill_in 'Contact e-mail', with: 'any@acme.test'
|
||||
fill_in 'Street', with: 'any'
|
||||
fill_in 'City', with: 'any'
|
||||
fill_in 'State / Province', with: 'any'
|
||||
fill_in 'Zip', with: 'any'
|
||||
select 'United States', from: 'Country'
|
||||
fill_in 'Accounting customer code', with: 'test'
|
||||
fill_in 'Code', with: 'test'
|
||||
click_on 'Create registrar'
|
||||
fill_in 'Name', with: 'Acme Ltd'
|
||||
fill_in 'Reg no', with: '1234'
|
||||
fill_in 'Contact e-mail', with: 'any@acme.test'
|
||||
fill_in 'Street', with: 'any'
|
||||
fill_in 'City', with: 'any'
|
||||
fill_in 'State / Province', with: 'any'
|
||||
fill_in 'Zip', with: 'any'
|
||||
select 'United States', from: 'Country'
|
||||
fill_in 'Accounting customer code', with: 'test'
|
||||
fill_in 'Code', with: 'test'
|
||||
click_on 'Create registrar'
|
||||
|
||||
assert_text 'Registrar has been successfully created'
|
||||
assert_text 'Acme Ltd'
|
||||
end
|
||||
assert_text 'Registrar has been successfully created'
|
||||
assert_text 'Acme Ltd'
|
||||
end
|
||||
|
||||
def test_updates_registrar
|
||||
|
|
|
@ -15,32 +15,30 @@ class BalanceTopUpTest < ApplicationSystemTestCase
|
|||
end
|
||||
|
||||
def test_creates_new_invoice
|
||||
if Feature.billing_system_integrated?
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response")
|
||||
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response")
|
||||
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice")
|
||||
.to_return(status: 200, body: "", headers: {})
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice")
|
||||
.to_return(status: 200, body: "", headers: {})
|
||||
|
||||
Setting.registry_vat_prc = 0.1
|
||||
Setting.registry_vat_prc = 0.1
|
||||
|
||||
visit registrar_invoices_url
|
||||
click_link_or_button 'Add deposit'
|
||||
fill_in 'Amount', with: '25.5'
|
||||
visit registrar_invoices_url
|
||||
click_link_or_button 'Add deposit'
|
||||
fill_in 'Amount', with: '25.5'
|
||||
|
||||
assert_difference 'Invoice.count' do
|
||||
click_link_or_button 'Add'
|
||||
end
|
||||
|
||||
invoice = Invoice.last
|
||||
|
||||
assert_equal BigDecimal(10), invoice.vat_rate
|
||||
assert_equal BigDecimal('28.05'), invoice.total
|
||||
assert_text 'Please pay the following invoice'
|
||||
assert_difference 'Invoice.count' do
|
||||
click_link_or_button 'Add'
|
||||
end
|
||||
|
||||
invoice = Invoice.last
|
||||
|
||||
assert_equal BigDecimal(10), invoice.vat_rate
|
||||
assert_equal BigDecimal('28.05'), invoice.total
|
||||
assert_text 'Please pay the following invoice'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,59 +17,55 @@ class NewInvoiceTest < ApplicationSystemTestCase
|
|||
end
|
||||
|
||||
def test_create_new_invoice_with_positive_amount
|
||||
if Feature.billing_system_integrated?
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
|
||||
visit registrar_invoices_path
|
||||
click_link_or_button 'Add deposit'
|
||||
fill_in 'Amount', with: '200.00'
|
||||
fill_in 'Description', with: 'My first invoice'
|
||||
visit registrar_invoices_path
|
||||
click_link_or_button 'Add deposit'
|
||||
fill_in 'Amount', with: '200.00'
|
||||
fill_in 'Description', with: 'My first invoice'
|
||||
|
||||
assert_difference 'Invoice.count', 1 do
|
||||
click_link_or_button 'Add'
|
||||
end
|
||||
|
||||
assert_text 'Please pay the following invoice'
|
||||
assert_text "Invoice no. #{invoice_n + 3}"
|
||||
assert_text 'Subtotal 200,00 €'
|
||||
assert_text 'Pay invoice'
|
||||
assert_difference 'Invoice.count', 1 do
|
||||
click_link_or_button 'Add'
|
||||
end
|
||||
|
||||
assert_text 'Please pay the following invoice'
|
||||
assert_text "Invoice no. #{invoice_n + 3}"
|
||||
assert_text 'Subtotal 200,00 €'
|
||||
assert_text 'Pay invoice'
|
||||
end
|
||||
|
||||
def test_create_new_invoice_with_comma_in_number
|
||||
if Feature.billing_system_integrated?
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
|
||||
visit registrar_invoices_path
|
||||
click_link_or_button 'Add deposit'
|
||||
fill_in 'Amount', with: '200,00'
|
||||
fill_in 'Description', with: 'My first invoice'
|
||||
visit registrar_invoices_path
|
||||
click_link_or_button 'Add deposit'
|
||||
fill_in 'Amount', with: '200,00'
|
||||
fill_in 'Description', with: 'My first invoice'
|
||||
|
||||
assert_difference 'Invoice.count', 1 do
|
||||
click_link_or_button 'Add'
|
||||
end
|
||||
|
||||
assert_text 'Please pay the following invoice'
|
||||
assert_text "Invoice no. #{invoice_n + 3}"
|
||||
assert_text 'Subtotal 200,00 €'
|
||||
assert_text 'Pay invoice'
|
||||
assert_difference 'Invoice.count', 1 do
|
||||
click_link_or_button 'Add'
|
||||
end
|
||||
|
||||
assert_text 'Please pay the following invoice'
|
||||
assert_text "Invoice no. #{invoice_n + 3}"
|
||||
assert_text 'Subtotal 200,00 €'
|
||||
assert_text 'Pay invoice'
|
||||
end
|
||||
|
||||
def test_create_new_invoice_fails_when_amount_is_0
|
||||
|
|
|
@ -84,11 +84,9 @@ class ProcessPaymentsTaskTest < ActiveJob::TestCase
|
|||
end
|
||||
|
||||
def test_if_invoice_is_overdue_than_48_hours
|
||||
return unless Feature.billing_system_integrated?
|
||||
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
|
||||
Spy.on_instance_method(SendEInvoiceTwoJob, :perform_now).and_return(true)
|
||||
Spy.on_instance_method(SendEInvoiceJob, :perform_now).and_return(true)
|
||||
|
||||
stub_request(:post, 'https://eis_billing_system:3000/api/v1/e_invoice/e_invoice')
|
||||
.to_return(status: 200, body: '', headers: {})
|
||||
|
@ -170,8 +168,6 @@ class ProcessPaymentsTaskTest < ActiveJob::TestCase
|
|||
end
|
||||
|
||||
def test_credits_registrar_athout_invoice_beforehand
|
||||
return unless Feature.billing_system_integrated?
|
||||
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator')
|
||||
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}")
|
||||
|
@ -179,7 +175,7 @@ class ProcessPaymentsTaskTest < ActiveJob::TestCase
|
|||
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator')
|
||||
.to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||
|
||||
Spy.on_instance_method(SendEInvoiceTwoJob, :perform_now).and_return(true)
|
||||
Spy.on_instance_method(SendEInvoiceJob, :perform_now).and_return(true)
|
||||
|
||||
stub_request(:post, 'https://eis_billing_system:3000/api/v1/e_invoice/e_invoice')
|
||||
.to_return(status: 200, body: '', headers: {})
|
||||
|
@ -208,8 +204,6 @@ class ProcessPaymentsTaskTest < ActiveJob::TestCase
|
|||
end
|
||||
|
||||
def test_topup_creates_invoice_and_send_it_as_paid
|
||||
return unless Feature.billing_system_integrated?
|
||||
|
||||
stub_request(:post, 'https://eis_billing_system:3000/api/v1/e_invoice/e_invoice')
|
||||
.to_return(status: 200, body: '', headers: {})
|
||||
|
||||
|
|
|
@ -21,30 +21,28 @@ class ReloadBalanceTaskTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_issues_invoice_when_auto_reload_is_enabled_and_threshold_reached
|
||||
if Feature.billing_system_integrated?
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
|
||||
reload_amount = 100
|
||||
registrar = registrar_with_auto_reload_enabled_and_threshold_reached(reload_amount)
|
||||
reload_amount = 100
|
||||
registrar = registrar_with_auto_reload_enabled_and_threshold_reached(reload_amount)
|
||||
|
||||
assert_difference -> { registrar.invoices.count } do
|
||||
capture_io { run_task }
|
||||
end
|
||||
|
||||
invoice = registrar.invoices.last
|
||||
assert_equal Time.zone.today, invoice.e_invoice_sent_at.to_date
|
||||
assert_difference -> { registrar.invoices.count } do
|
||||
capture_io { run_task }
|
||||
end
|
||||
|
||||
invoice = registrar.invoices.last
|
||||
assert_equal Time.zone.today, invoice.e_invoice_sent_at.to_date
|
||||
end
|
||||
|
||||
def test_skips_issuing_invoice_when_threshold_is_not_reached
|
||||
|
@ -66,51 +64,47 @@ class ReloadBalanceTaskTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_marks_registrar_as_pending_balance_reload
|
||||
if Feature.billing_system_integrated?
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
|
||||
registrar = registrar_with_auto_reload_enabled_and_threshold_reached
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
|
||||
capture_io { run_task }
|
||||
registrar.reload
|
||||
registrar = registrar_with_auto_reload_enabled_and_threshold_reached
|
||||
|
||||
assert registrar.settings['balance_auto_reload']['pending']
|
||||
end
|
||||
capture_io { run_task }
|
||||
registrar.reload
|
||||
|
||||
assert registrar.settings['balance_auto_reload']['pending']
|
||||
end
|
||||
|
||||
def test_output
|
||||
if Feature.billing_system_integrated?
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||
to_return(status: 200, body: "", headers: {})
|
||||
|
||||
reload_amount = 100
|
||||
registrar = registrar_with_auto_reload_enabled_and_threshold_reached(reload_amount)
|
||||
assert_equal 'Best Names', registrar.name
|
||||
reload_amount = 100
|
||||
registrar = registrar_with_auto_reload_enabled_and_threshold_reached(reload_amount)
|
||||
assert_equal 'Best Names', registrar.name
|
||||
|
||||
assert_output %(Registrar "Best Names" got #{number_to_currency(reload_amount, unit: 'EUR')}\nInvoiced total: 1\n) do
|
||||
run_task
|
||||
end
|
||||
assert_output %(Registrar "Best Names" got #{number_to_currency(reload_amount, unit: 'EUR')}\nInvoiced total: 1\n) do
|
||||
run_task
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue