mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 07:04:47 +02:00
Resolve merge errors
This commit is contained in:
commit
73e9dd6870
817 changed files with 16875 additions and 17443 deletions
|
@ -1,61 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ConvertDomainDeleteDateTaskTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
||||
def test_moves_domain_delete_date_one_day_ahead
|
||||
@domain.update!(delete_date: '2010-07-05')
|
||||
|
||||
capture_io do
|
||||
run_task
|
||||
end
|
||||
@domain.reload
|
||||
|
||||
assert_equal Date.parse('2010-07-06'), @domain.delete_date
|
||||
end
|
||||
|
||||
def test_processes_invalid_domains
|
||||
@domain = domains(:invalid)
|
||||
@domain.update_columns(delete_date: '2010-07-05')
|
||||
|
||||
capture_io do
|
||||
run_task
|
||||
end
|
||||
@domain.reload
|
||||
|
||||
assert_equal Date.parse('2010-07-06'), @domain.delete_date
|
||||
end
|
||||
|
||||
def test_skips_non_expired_domains
|
||||
@domain.update!(delete_date: nil)
|
||||
|
||||
assert_nothing_raised do
|
||||
capture_io do
|
||||
run_task
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_output
|
||||
eliminate_effect_of_all_domains_except(@domain)
|
||||
@domain.update!(delete_date: '2010-07-05')
|
||||
|
||||
assert_output "Domains processed: 1\n" do
|
||||
run_task
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def eliminate_effect_of_all_domains_except(domain)
|
||||
Domain.connection.disable_referential_integrity do
|
||||
Domain.delete_all("id != #{domain.id}")
|
||||
end
|
||||
end
|
||||
|
||||
def run_task
|
||||
Rake::Task['data_migrations:convert_domain_delete_date'].execute
|
||||
end
|
||||
end
|
63
test/tasks/emails/verify_email_task_test.rb
Normal file
63
test/tasks/emails/verify_email_task_test.rb
Normal file
|
@ -0,0 +1,63 @@
|
|||
require 'test_helper'
|
||||
|
||||
class VerifyEmailTaskTest < ActiveSupport::TestCase
|
||||
|
||||
def setup
|
||||
@contact = contacts(:john)
|
||||
@invalid_contact = contacts(:invalid_email)
|
||||
@contact_verification = @contact.email_verification
|
||||
@invalid_contact_verification = @invalid_contact.email_verification
|
||||
|
||||
@default_whitelist = Truemail.configure.whitelisted_domains
|
||||
@default_blacklist = Truemail.configure.blacklisted_domains
|
||||
Truemail.configure.whitelisted_domains = whitelisted_domains
|
||||
Truemail.configure.blacklisted_domains = blacklisted_domains
|
||||
end
|
||||
|
||||
def teardown
|
||||
Truemail.configure.whitelisted_domains = @default_whitelist
|
||||
Truemail.configure.blacklisted_domains = @default_blacklist
|
||||
end
|
||||
|
||||
def domain(email)
|
||||
Mail::Address.new(email).domain
|
||||
rescue Mail::Field::IncompleteParseError
|
||||
nil
|
||||
end
|
||||
|
||||
def whitelisted_domains
|
||||
[domain(@contact.email)].reject(&:blank?)
|
||||
end
|
||||
|
||||
def blacklisted_domains
|
||||
[domain(@invalid_contact.email)].reject(&:blank?)
|
||||
end
|
||||
|
||||
def test_tasks_verifies_emails
|
||||
capture_io { run_task }
|
||||
|
||||
@contact_verification.reload
|
||||
@invalid_contact_verification.reload
|
||||
|
||||
assert @contact_verification.verified?
|
||||
assert @invalid_contact_verification.failed?
|
||||
end
|
||||
|
||||
def test_domain_task_verifies_for_one_domain
|
||||
capture_io { run_single_domain_task(@contact_verification.domain) }
|
||||
|
||||
@contact_verification.reload
|
||||
@invalid_contact_verification.reload
|
||||
|
||||
assert @contact_verification.verified?
|
||||
assert @invalid_contact_verification.not_verified?
|
||||
end
|
||||
|
||||
def run_task
|
||||
Rake::Task['verify_email:all_domains'].execute
|
||||
end
|
||||
|
||||
def run_single_domain_task(domain)
|
||||
Rake::Task["verify_email:domain"].invoke(domain)
|
||||
end
|
||||
end
|
|
@ -31,7 +31,7 @@ class CancelOverdueInvoicesTaskTest < ActiveSupport::TestCase
|
|||
|
||||
def eliminate_effect_of_other_invoices
|
||||
Invoice.connection.disable_referential_integrity do
|
||||
Invoice.delete_all("id != #{@invoice.id}")
|
||||
Invoice.where("id != #{@invoice.id}").delete_all
|
||||
end
|
||||
end
|
||||
|
||||
|
|
108
test/tasks/invoices/process_payments_test.rb
Normal file
108
test/tasks/invoices/process_payments_test.rb
Normal file
|
@ -0,0 +1,108 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ProcessPaymentsTaskTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@payment_amount = payment_amount = 0.1
|
||||
@payment_currency = payment_currency = 'EUR'
|
||||
@payment_date = payment_date = Date.parse('2010-07-05')
|
||||
@payment_reference_number = payment_reference_number = '13'
|
||||
@payment_description = payment_description = @invoice_number = '1234'
|
||||
beneficiary_iban = 'GB33BUKB20201555555555'
|
||||
|
||||
@invoice = create_payable_invoice(number: @invoice_number,
|
||||
total: payment_amount,
|
||||
currency: @payment_currency,
|
||||
reference_no: @payment_reference_number)
|
||||
Setting.registry_iban = beneficiary_iban
|
||||
|
||||
Lhv::ConnectApi.class_eval do
|
||||
define_method :credit_debit_notification_messages do
|
||||
transaction = OpenStruct.new(amount: payment_amount,
|
||||
currency: payment_currency,
|
||||
date: payment_date,
|
||||
payment_reference_number: payment_reference_number,
|
||||
payment_description: payment_description)
|
||||
message = OpenStruct.new(bank_account_iban: beneficiary_iban,
|
||||
credit_transactions: [transaction])
|
||||
[message]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_doubles_are_valid
|
||||
assert Lhv::ConnectApi.method_defined?(:credit_debit_notification_messages)
|
||||
assert Lhv::ConnectApi::Messages::CreditDebitNotification.method_defined?(:bank_account_iban)
|
||||
assert Lhv::ConnectApi::Messages::CreditDebitNotification.method_defined?(:credit_transactions)
|
||||
end
|
||||
|
||||
def test_saves_transactions
|
||||
assert_difference 'BankStatement.count' do
|
||||
assert_difference 'BankTransaction.count' do
|
||||
capture_io { run_task }
|
||||
end
|
||||
end
|
||||
transaction = BankTransaction.last
|
||||
assert_equal @payment_amount, transaction.sum
|
||||
assert_equal @payment_currency, transaction.currency
|
||||
assert_equal @payment_date, transaction.paid_at.to_date
|
||||
assert_equal @payment_reference_number, transaction.reference_no
|
||||
assert_equal @payment_description, transaction.description
|
||||
end
|
||||
|
||||
def test_marks_matched_invoice_as_paid
|
||||
assert @invoice.unpaid?
|
||||
|
||||
capture_io { run_task }
|
||||
@invoice.reload
|
||||
|
||||
assert @invoice.paid?
|
||||
end
|
||||
|
||||
def test_attaches_paid_payment_order_to_invoice
|
||||
assert @invoice.unpaid?
|
||||
|
||||
capture_io { run_task }
|
||||
@invoice.reload
|
||||
|
||||
payment_order = @invoice.payment_orders.last
|
||||
assert_equal 'PaymentOrders::SystemPayment', payment_order.type
|
||||
assert payment_order.paid?
|
||||
end
|
||||
|
||||
def test_attaches_failed_payment_order_to_invoice
|
||||
assert @invoice.unpaid?
|
||||
account = accounts(:cash)
|
||||
account.update!(registrar: registrars(:goodnames))
|
||||
|
||||
capture_io { run_task }
|
||||
@invoice.reload
|
||||
|
||||
payment_order = @invoice.payment_orders.last
|
||||
assert_equal 'PaymentOrders::SystemPayment', payment_order.type
|
||||
assert payment_order.failed?
|
||||
end
|
||||
|
||||
def test_output
|
||||
assert_output "Transactions processed: 1\n" do
|
||||
run_task
|
||||
end
|
||||
end
|
||||
|
||||
def test_parses_keystore_properly
|
||||
assert_nothing_raised do
|
||||
run_task
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def run_task
|
||||
Rake::Task['invoices:process_payments'].execute
|
||||
end
|
||||
|
||||
def create_payable_invoice(attributes = {})
|
||||
invoice = invoices(:one)
|
||||
invoice.update!({ account_activity: nil, cancelled_at: nil }.merge(attributes))
|
||||
invoice
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue