mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 11:38:30 +02:00
Merge remote-tracking branch 'origin/master' into refactor-contact-archivation
This commit is contained in:
commit
ab1fa9064e
47 changed files with 453 additions and 290 deletions
1
test/fixtures/domains.yml
vendored
1
test/fixtures/domains.yml
vendored
|
@ -5,7 +5,6 @@ shop:
|
|||
registrar: bestnames
|
||||
registrant: john
|
||||
transfer_code: 65078d5
|
||||
registered_at: <%= Time.zone.parse('2010-07-04').to_s(:db) %>
|
||||
valid_to: <%= Time.zone.parse('2010-07-05').to_s(:db) %>
|
||||
outzone_at: <%= Time.zone.parse('2010-07-06').to_s(:db) %>
|
||||
delete_date: 2010-07-07
|
||||
|
|
4
test/fixtures/setting_entries.yml
vendored
4
test/fixtures/setting_entries.yml
vendored
|
@ -182,8 +182,8 @@ registrar_ip_whitelist_enabled:
|
|||
created_at: <%= Time.zone.parse('2010-07-05') %>
|
||||
updated_at: <%= Time.zone.parse('2010-07-05') %>
|
||||
|
||||
request_confrimation_on_registrant_change_enabled:
|
||||
code: request_confrimation_on_registrant_change_enabled
|
||||
request_confirmation_on_registrant_change_enabled:
|
||||
code: request_confirmation_on_registrant_change_enabled
|
||||
value: 'true'
|
||||
group: other
|
||||
format: boolean
|
||||
|
|
|
@ -6,12 +6,12 @@ class EppDomainUpdateBaseTest < EppTestCase
|
|||
setup do
|
||||
@domain = domains(:shop)
|
||||
@original_registrant_change_verification =
|
||||
Setting.request_confrimation_on_registrant_change_enabled
|
||||
Setting.request_confirmation_on_registrant_change_enabled
|
||||
ActionMailer::Base.deliveries.clear
|
||||
end
|
||||
|
||||
teardown do
|
||||
Setting.request_confrimation_on_registrant_change_enabled =
|
||||
Setting.request_confirmation_on_registrant_change_enabled =
|
||||
@original_registrant_change_verification
|
||||
end
|
||||
|
||||
|
@ -87,7 +87,7 @@ class EppDomainUpdateBaseTest < EppTestCase
|
|||
end
|
||||
|
||||
def test_requires_verification_from_current_registrant_when_provided_registrant_is_a_new_one
|
||||
Setting.request_confrimation_on_registrant_change_enabled = true
|
||||
Setting.request_confirmation_on_registrant_change_enabled = true
|
||||
new_registrant = contacts(:william).becomes(Registrant)
|
||||
assert_not_equal new_registrant, @domain.registrant
|
||||
|
||||
|
@ -124,7 +124,7 @@ class EppDomainUpdateBaseTest < EppTestCase
|
|||
end
|
||||
|
||||
def test_requires_verification_from_current_registrant_when_not_yet_verified_by_registrar
|
||||
Setting.request_confrimation_on_registrant_change_enabled = true
|
||||
Setting.request_confirmation_on_registrant_change_enabled = true
|
||||
new_registrant = contacts(:william)
|
||||
assert_not_equal new_registrant, @domain.registrant
|
||||
|
||||
|
@ -161,7 +161,7 @@ class EppDomainUpdateBaseTest < EppTestCase
|
|||
end
|
||||
|
||||
def test_updates_registrant_when_legaldoc_is_not_mandatory
|
||||
Setting.request_confrimation_on_registrant_change_enabled = true
|
||||
Setting.request_confirmation_on_registrant_change_enabled = true
|
||||
new_registrant = contacts(:william)
|
||||
assert_not_equal new_registrant, @domain.registrant
|
||||
|
||||
|
@ -197,7 +197,7 @@ class EppDomainUpdateBaseTest < EppTestCase
|
|||
end
|
||||
|
||||
def test_dows_not_update_registrant_when_legaldoc_is_mandatory
|
||||
Setting.request_confrimation_on_registrant_change_enabled = true
|
||||
Setting.request_confirmation_on_registrant_change_enabled = true
|
||||
old_value = Setting.legal_document_is_mandatory
|
||||
Setting.legal_document_is_mandatory = true
|
||||
new_registrant = contacts(:william)
|
||||
|
@ -226,7 +226,7 @@ class EppDomainUpdateBaseTest < EppTestCase
|
|||
end
|
||||
|
||||
def test_skips_verification_when_provided_registrant_is_the_same_as_current_one
|
||||
Setting.request_confrimation_on_registrant_change_enabled = true
|
||||
Setting.request_confirmation_on_registrant_change_enabled = true
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
@ -260,7 +260,7 @@ class EppDomainUpdateBaseTest < EppTestCase
|
|||
end
|
||||
|
||||
def test_skips_verification_when_registrant_changed_with_dispute_password
|
||||
Setting.request_confrimation_on_registrant_change_enabled = true
|
||||
Setting.request_confirmation_on_registrant_change_enabled = true
|
||||
dispute = disputes(:expired)
|
||||
dispute.update!(starts_at: Time.zone.now, expires_at: Time.zone.now + 5.days, closed: nil)
|
||||
new_registrant = contacts(:william)
|
||||
|
@ -303,7 +303,7 @@ class EppDomainUpdateBaseTest < EppTestCase
|
|||
end
|
||||
|
||||
def test_skips_verification_when_disabled
|
||||
Setting.request_confrimation_on_registrant_change_enabled = false
|
||||
Setting.request_confirmation_on_registrant_change_enabled = false
|
||||
new_registrant = contacts(:william).becomes(Registrant)
|
||||
assert_not_equal new_registrant, @domain.registrant
|
||||
|
||||
|
@ -340,7 +340,7 @@ class EppDomainUpdateBaseTest < EppTestCase
|
|||
end
|
||||
|
||||
def test_skips_verification_from_current_registrant_when_already_verified_by_registrar
|
||||
Setting.request_confrimation_on_registrant_change_enabled = true
|
||||
Setting.request_confirmation_on_registrant_change_enabled = true
|
||||
new_registrant = contacts(:william).becomes(Registrant)
|
||||
assert_not_equal new_registrant, @domain.registrant
|
||||
|
||||
|
@ -377,7 +377,7 @@ class EppDomainUpdateBaseTest < EppTestCase
|
|||
end
|
||||
|
||||
def test_clears_force_delete_when_registrar_changed
|
||||
Setting.request_confrimation_on_registrant_change_enabled = true
|
||||
Setting.request_confirmation_on_registrant_change_enabled = true
|
||||
new_registrant = contacts(:william).becomes(Registrant)
|
||||
@domain.schedule_force_delete(type: :fast_track)
|
||||
assert_not_equal new_registrant, @domain.registrant
|
||||
|
|
|
@ -151,4 +151,44 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
|||
DirectoInvoiceForwardJob.run(monthly: true, dry: false)
|
||||
end
|
||||
end
|
||||
|
||||
def test_sends_each_monthly_invoice_separately
|
||||
WebMock.reset!
|
||||
|
||||
activity = account_activities(:one)
|
||||
price = billing_prices(:create_one_year)
|
||||
price.update(duration: '3 years')
|
||||
activity.update(activity_type: 'create', price: price)
|
||||
|
||||
# Creating account activity for second action
|
||||
another_activity = activity.dup
|
||||
another_activity.account = accounts(:two)
|
||||
|
||||
AccountActivity.skip_callback(:create, :after, :update_balance)
|
||||
another_activity.created_at = Time.zone.parse('2010-07-05 10:00')
|
||||
another_activity.save
|
||||
AccountActivity.set_callback(:create, :after, :update_balance)
|
||||
|
||||
response = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<results>
|
||||
<Result Type="0" Desc="OK" docid="309902" doctype="ARVE" submit="Invoices"/>
|
||||
</results>
|
||||
XML
|
||||
|
||||
first_registrar_stub = stub_request(:post, ENV['directo_invoice_url']).with do |request|
|
||||
body = CGI.unescape(request.body)
|
||||
(body.include? 'StartDate') && (body.include? 'EndDate') && (body.include? 'bestnames')
|
||||
end.to_return(status: 200, body: response)
|
||||
|
||||
second_registrar_stub = stub_request(:post, ENV['directo_invoice_url']).with do |request|
|
||||
body = CGI.unescape(request.body)
|
||||
(body.include? 'StartDate') && (body.include? 'EndDate') && (body.include? 'goodnames')
|
||||
end.to_return(status: 200, body: response)
|
||||
|
||||
DirectoInvoiceForwardJob.run(monthly: true, dry: false)
|
||||
|
||||
assert_requested first_registrar_stub
|
||||
assert_requested second_registrar_stub
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ class SendEInvoiceJobTest < ActiveSupport::TestCase
|
|||
EInvoice::Providers::TestProvider.deliveries.clear
|
||||
|
||||
assert_nothing_raised do
|
||||
SendEInvoiceJob.enqueue(@invoice.id)
|
||||
SendEInvoiceJob.enqueue(@invoice.id, true)
|
||||
end
|
||||
@invoice.reload
|
||||
|
||||
|
@ -29,7 +29,7 @@ class SendEInvoiceJobTest < ActiveSupport::TestCase
|
|||
stub_request(:get, "https://testfinance.post.ee/finance/erp/erpServices.wsdl").to_timeout
|
||||
|
||||
assert_raise HTTPClient::TimeoutError do
|
||||
SendEInvoiceJob.enqueue(@invoice.id)
|
||||
SendEInvoiceJob.enqueue(@invoice.id, true)
|
||||
end
|
||||
assert @invoicee_invoice_sent_at.blank?
|
||||
|
||||
|
@ -37,7 +37,7 @@ class SendEInvoiceJobTest < ActiveSupport::TestCase
|
|||
EInvoice::Providers::TestProvider.deliveries.clear
|
||||
|
||||
assert_nothing_raised do
|
||||
SendEInvoiceJob.enqueue(@invoice.id)
|
||||
SendEInvoiceJob.enqueue(@invoice.id, true)
|
||||
end
|
||||
@invoice.reload
|
||||
|
||||
|
|
|
@ -26,14 +26,12 @@ class BankTransactionTest < ActiveSupport::TestCase
|
|||
another_item.save
|
||||
another_invoice.reload
|
||||
|
||||
first_transaction = BankTransaction.new(description: 'invoice #2221',
|
||||
sum: 10,
|
||||
first_transaction = BankTransaction.new(sum: 10,
|
||||
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
||||
|
||||
first_transaction.create_activity(another_invoice.buyer, another_invoice)
|
||||
|
||||
transaction = BankTransaction.new(description: 'invoice #2222',
|
||||
sum: 10,
|
||||
transaction = BankTransaction.new(sum: 10,
|
||||
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
||||
|
||||
assert_difference 'AccountActivity.count' do
|
||||
|
@ -54,8 +52,7 @@ class BankTransactionTest < ActiveSupport::TestCase
|
|||
another_invoice.reload
|
||||
another_invoice.update(reference_no: '1234567', number: '2221', cancelled_at: Time.zone.now)
|
||||
|
||||
transaction = BankTransaction.new(description: 'invoice #2222',
|
||||
sum: 10,
|
||||
transaction = BankTransaction.new(sum: 10,
|
||||
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
||||
|
||||
assert_difference 'AccountActivity.count' do
|
||||
|
@ -74,8 +71,7 @@ class BankTransactionTest < ActiveSupport::TestCase
|
|||
another_item.save
|
||||
another_invoice.reload
|
||||
|
||||
transaction = BankTransaction.new(description: 'invoice #2222',
|
||||
sum: 10,
|
||||
transaction = BankTransaction.new(sum: 10,
|
||||
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
||||
|
||||
assert_difference 'AccountActivity.count' do
|
||||
|
@ -90,8 +86,7 @@ class BankTransactionTest < ActiveSupport::TestCase
|
|||
|
||||
def test_matches_against_invoice_nubmber_and_reference_number_in_description
|
||||
create_payable_invoice(number: '2222', total: 10, reference_no: '1234567')
|
||||
transaction = BankTransaction.new(description: 'invoice #2222',
|
||||
sum: 10,
|
||||
transaction = BankTransaction.new(sum: 10,
|
||||
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
||||
|
||||
assert_difference 'AccountActivity.count' do
|
||||
|
@ -99,6 +94,18 @@ class BankTransactionTest < ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_no_errors_if_no_valid_refnumber_in_description
|
||||
create_payable_invoice(number: '2222', total: 10, reference_no: '1234567')
|
||||
transaction = BankTransaction.new(sum: 10,
|
||||
description: 'Order nr 1 from registrar 123456')
|
||||
|
||||
assert_no_difference 'AccountActivity.count' do
|
||||
assert_nothing_raised do
|
||||
transaction.autobind_invoice
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_resets_pending_registrar_balance_reload
|
||||
registrar = registrar_with_pending_balance_auto_reload
|
||||
create_payable_invoice(number: '2222', total: 10, reference_no: '1111')
|
||||
|
@ -149,6 +156,24 @@ class BankTransactionTest < ActiveSupport::TestCase
|
|||
assert transaction.errors.full_messages.include?('Cannot bind cancelled invoice')
|
||||
end
|
||||
|
||||
def test_assumes_7_digit_number_is_reference_no_in_desc
|
||||
statement = BankTransaction.new
|
||||
statement.description = 'number 1234567 defo valid'
|
||||
assert_equal '1234567', statement.parsed_ref_number
|
||||
end
|
||||
|
||||
def test_determines_correct_ref_no_from_description
|
||||
statement = BankTransaction.new
|
||||
ref_no = registrars(:bestnames).reference_no
|
||||
statement.description = "invoice 123 125 55 4521 #{ref_no} 7541 defo valid"
|
||||
assert_equal ref_no.to_s, statement.parsed_ref_number
|
||||
end
|
||||
|
||||
def test_parsed_ref_no_returns_nil_if_ref_not_found
|
||||
statement = BankTransaction.new
|
||||
statement.description = "all invalid 12 123 55 77777 --"
|
||||
assert_nil statement.parsed_ref_number
|
||||
end
|
||||
private
|
||||
|
||||
def create_payable_invoice(attributes)
|
||||
|
|
|
@ -425,6 +425,12 @@ class DomainTest < ActiveSupport::TestCase
|
|||
assert_not(@domain.force_delete_scheduled?)
|
||||
end
|
||||
|
||||
def test_aliases_registered_at_to_created_at
|
||||
created_at = Time.zone.parse('2010-07-05 10:00')
|
||||
domain = Domain.new(created_at: created_at)
|
||||
assert_equal created_at, domain.registered_at
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid_domain
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
require 'test_helper'
|
||||
|
||||
class InvoiceTest < ActiveSupport::TestCase
|
||||
include ActionMailer::TestHelper
|
||||
|
||||
setup do
|
||||
@invoice = invoices(:one)
|
||||
end
|
||||
|
@ -109,4 +111,33 @@ class InvoiceTest < ActiveSupport::TestCase
|
|||
seller_zip: nil)
|
||||
assert_equal 'street, city, state', invoice.seller_address
|
||||
end
|
||||
|
||||
def test_creates_invoice_with_bank_transaction_total
|
||||
registrar = registrars(:bestnames)
|
||||
transaction = bank_transactions(:one).dup
|
||||
transaction.reference_no = registrar.reference_no
|
||||
transaction.sum = 250
|
||||
|
||||
invoice = Invoice.create_from_transaction!(transaction)
|
||||
assert_equal 250, invoice.total
|
||||
|
||||
transaction.sum = 146.88
|
||||
invoice = Invoice.create_from_transaction!(transaction)
|
||||
assert_equal 146.88, invoice.total
|
||||
|
||||
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
|
||||
registrar = registrars(:bestnames)
|
||||
transaction = bank_transactions(:one).dup
|
||||
transaction.reference_no = registrar.reference_no
|
||||
transaction.sum = 250
|
||||
|
||||
assert_emails 1 do
|
||||
Invoice.create_from_transaction!(transaction)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,11 +6,48 @@ class AdminAreaBankStatementTest < ApplicationSystemTestCase
|
|||
travel_to Time.zone.parse('2010-07-05 00:30:00')
|
||||
end
|
||||
|
||||
def test_import_statement
|
||||
assert_difference 'BankStatement.count', 1 do
|
||||
visit import_admin_bank_statements_path
|
||||
attach_file 'Th6 file', Rails.root.join('test', 'fixtures', 'files', 'bank_statement_test.txt').to_s
|
||||
click_link_or_button 'Save'
|
||||
end
|
||||
def test_can_create_statement_manually
|
||||
create_bank_statement
|
||||
assert_text 'Record created'
|
||||
end
|
||||
|
||||
def test_can_add_transaction_to_statement_manually
|
||||
create_bank_statement
|
||||
click_link_or_button 'Add'
|
||||
assert_text 'Create bank transaction'
|
||||
|
||||
fill_in 'Description', with: 'Invoice with id 123'
|
||||
fill_in 'Reference number', with: '1232'
|
||||
fill_in 'Sum', with: '500'
|
||||
fill_in 'Paid at', with: Time.zone.today.to_s
|
||||
click_link_or_button 'Save'
|
||||
assert_text 'Record created'
|
||||
end
|
||||
|
||||
def test_can_bind_statement_transactions
|
||||
registrar = registrars(:bestnames)
|
||||
registrar.issue_prepayment_invoice(amount: 500)
|
||||
invoice = registrar.invoices.last
|
||||
|
||||
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'
|
||||
|
||||
click_link_or_button 'Back to bank statement'
|
||||
click_link_or_button 'Bind invoices'
|
||||
|
||||
assert_text 'Invoices were fully binded'
|
||||
end
|
||||
|
||||
def create_bank_statement
|
||||
visit admin_bank_statements_path
|
||||
click_link_or_button 'Add'
|
||||
click_link_or_button 'Save'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ class RegistrantAreaDomainDetailsTest < ApplicationSystemTestCase
|
|||
visit registrant_domain_url(@domain)
|
||||
|
||||
assert_text 'Name shop.test'
|
||||
assert_text "Registered at #{l Time.zone.parse('2010-07-04')}"
|
||||
assert_text "Registered at #{l @domain.registered_at}"
|
||||
assert_link 'Best Names', href: registrant_registrar_path(@domain.registrar)
|
||||
|
||||
assert_text 'Transfer code'
|
||||
|
@ -73,4 +73,4 @@ class RegistrantAreaDomainDetailsTest < ApplicationSystemTestCase
|
|||
|
||||
assert_field nil, with: registrant_domain_update_confirm_url(@domain, token: 'a01')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -82,6 +82,25 @@ class ProcessPaymentsTaskTest < ActiveSupport::TestCase
|
|||
assert payment_order.failed?
|
||||
end
|
||||
|
||||
def test_credits_registrar_account_without_invoice_beforehand
|
||||
registrar = registrars(:bestnames)
|
||||
|
||||
assert_changes -> { registrar.accounts.first.balance } do
|
||||
run_task
|
||||
end
|
||||
|
||||
assert_changes -> { registrar.invoices.count } do
|
||||
run_task
|
||||
end
|
||||
end
|
||||
|
||||
def test_topup_creates_invoice_with_total_of_transactioned_amount
|
||||
registrar = registrars(:bestnames)
|
||||
run_task
|
||||
|
||||
assert_equal 0.1, registrar.invoices.last.total
|
||||
end
|
||||
|
||||
def test_output
|
||||
assert_output "Transactions processed: 1\n" do
|
||||
run_task
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue