mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 19:20:37 +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
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue