mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 16:32:04 +02:00
Merge remote-tracking branch 'origin/master' into 1422-record-payment-method-and-failed-payments
This commit is contained in:
commit
5d999f96c5
75 changed files with 847 additions and 782 deletions
|
@ -5,7 +5,7 @@ class ContactAuditLogTest < ActionDispatch::IntegrationTest
|
|||
contact = contacts(:john)
|
||||
|
||||
contact.legal_document_id = 1
|
||||
assert_difference 'contact.versions.count' do
|
||||
assert_difference 'contact.versions.count', 1 do
|
||||
contact.save!
|
||||
end
|
||||
|
||||
|
@ -13,4 +13,4 @@ class ContactAuditLogTest < ActionDispatch::IntegrationTest
|
|||
assert_equal ({ legal_documents: [1] }).with_indifferent_access,
|
||||
contact_version.children.with_indifferent_access
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ class DomainAuditLogTest < ActionDispatch::IntegrationTest
|
|||
assert_equal registrant_id, domain.registrant_id
|
||||
domain.legal_document_id = legal_document_id
|
||||
|
||||
assert_difference 'domain.versions.count' do
|
||||
assert_difference 'domain.versions.count', 1 do
|
||||
domain.save!
|
||||
end
|
||||
|
||||
|
@ -26,4 +26,4 @@ class DomainAuditLogTest < ActionDispatch::IntegrationTest
|
|||
assert_equal [legal_document_id], domain_version.children['legal_documents']
|
||||
assert_equal [registrant_id], domain_version.children['registrant']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegenerateRegistrarReferenceNumbersTaskTest < ActiveSupport::TestCase
|
||||
def test_regenerates_registrar_reference_numbers_to_estonian_format
|
||||
registrar = registrars(:bestnames)
|
||||
registrar.update_column(:reference_no, 'RF1111')
|
||||
|
||||
capture_io { run_task }
|
||||
registrar.reload
|
||||
|
||||
assert_not registrar.reference_no.start_with?('RF')
|
||||
end
|
||||
|
||||
def test_bypasses_registrar_validation
|
||||
registrar = registrars(:invalid)
|
||||
registrar.update_column(:reference_no, 'RF1111')
|
||||
assert registrar.invalid?
|
||||
|
||||
capture_io { run_task }
|
||||
registrar.reload
|
||||
|
||||
assert_not registrar.reference_no.start_with?('RF')
|
||||
end
|
||||
|
||||
def test_does_not_regenerate_when_the_task_is_run_again
|
||||
registrar = registrars(:bestnames)
|
||||
registrar.update!(reference_no: '1111')
|
||||
|
||||
capture_io { run_task }
|
||||
registrar.reload
|
||||
|
||||
assert_equal '1111', registrar.reference_no
|
||||
end
|
||||
|
||||
def test_keeps_iso_reference_number_on_the_invoice_unchanged
|
||||
registrar = registrars(:bestnames)
|
||||
registrar.update_column(:reference_no, 'RF1111')
|
||||
invoice = invoices(:one)
|
||||
invoice.update!(reference_no: 'RF2222')
|
||||
|
||||
capture_io { run_task }
|
||||
invoice.reload
|
||||
|
||||
assert_equal 'RF2222', invoice.reference_no
|
||||
end
|
||||
|
||||
def test_output
|
||||
registrar = registrars(:bestnames)
|
||||
registrar.update_column(:reference_no, 'RF1111')
|
||||
|
||||
assert_output "Registrars processed: 1\n" do
|
||||
run_task
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def run_task
|
||||
Rake::Task['data_migrations:regenerate_registrar_reference_numbers'].execute
|
||||
end
|
||||
end
|
47
test/jobs/send_e_invoice_job_test.rb
Normal file
47
test/jobs/send_e_invoice_job_test.rb
Normal file
|
@ -0,0 +1,47 @@
|
|||
require 'test_helper'
|
||||
|
||||
class SendEInvoiceJobTest < ActiveSupport::TestCase
|
||||
|
||||
def teardown
|
||||
EInvoice.provider = EInvoice::Providers::TestProvider.new
|
||||
EInvoice::Providers::TestProvider.deliveries.clear
|
||||
end
|
||||
|
||||
def test_if_invoice_is_sended
|
||||
@invoice = invoices(:one)
|
||||
EInvoice.provider = EInvoice::Providers::TestProvider.new
|
||||
EInvoice::Providers::TestProvider.deliveries.clear
|
||||
|
||||
assert_nothing_raised do
|
||||
SendEInvoiceJob.enqueue(@invoice.id)
|
||||
end
|
||||
@invoice.reload
|
||||
|
||||
assert_not @invoice.e_invoice_sent_at.blank?
|
||||
assert_equal 1, EInvoice::Providers::TestProvider.deliveries.count
|
||||
end
|
||||
|
||||
def test_if_invoice_sending_retries
|
||||
@invoice = invoices(:one)
|
||||
provider_config = { password: nil,
|
||||
test_mode: true }
|
||||
EInvoice.provider = EInvoice::Providers::OmnivaProvider.new(provider_config)
|
||||
stub_request(:get, "https://testfinance.post.ee/finance/erp/erpServices.wsdl").to_timeout
|
||||
|
||||
assert_raise HTTPClient::TimeoutError do
|
||||
SendEInvoiceJob.enqueue(@invoice.id)
|
||||
end
|
||||
assert @invoicee_invoice_sent_at.blank?
|
||||
|
||||
EInvoice.provider = EInvoice::Providers::TestProvider.new
|
||||
EInvoice::Providers::TestProvider.deliveries.clear
|
||||
|
||||
assert_nothing_raised do
|
||||
SendEInvoiceJob.enqueue(@invoice.id)
|
||||
end
|
||||
@invoice.reload
|
||||
|
||||
assert_not @invoice.e_invoice_sent_at.blank?
|
||||
assert_equal 1, EInvoice::Providers::TestProvider.deliveries.count
|
||||
end
|
||||
end
|
|
@ -21,6 +21,25 @@ class PaperTrailLearningTest < ActiveSupport::TestCase
|
|||
assert_respond_to @record.versions.first, :item_id
|
||||
end
|
||||
|
||||
def test_returns_version_count_on_domains
|
||||
@domain = domains(:airport)
|
||||
@domain.save
|
||||
|
||||
assert_equal 1, @domain.versions.count
|
||||
|
||||
@domain.name = 'domain.test'
|
||||
@domain.save!
|
||||
assert_equal 2, @domain.versions.count
|
||||
end
|
||||
|
||||
def test_returns_version_count_on_users
|
||||
@user = users(:registrant)
|
||||
|
||||
@user.email = 'aaa@bbb.com'
|
||||
@user.save!
|
||||
assert_equal 1, @user.versions.count
|
||||
end
|
||||
|
||||
def test_creates_new_version_upon_update
|
||||
@record = Post.create!(title: 'old title')
|
||||
original_record = @record.clone
|
||||
|
@ -40,7 +59,7 @@ class PaperTrailLearningTest < ActiveSupport::TestCase
|
|||
@record = Post.create!(title: 'any')
|
||||
|
||||
assert_difference -> { @record.versions.size } do
|
||||
@record.touch_with_version
|
||||
@record.paper_trail.touch_with_version
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -36,22 +36,22 @@ class DepositTest < ActiveSupport::TestCase
|
|||
|
||||
def test_amount_is_converted_from_string
|
||||
@deposit.amount = "12.00"
|
||||
assert_equal(BigDecimal.new("12.00"), @deposit.amount)
|
||||
assert_equal(BigDecimal("12.00"), @deposit.amount)
|
||||
|
||||
@deposit.amount = "12,11"
|
||||
assert_equal(BigDecimal.new("12.11"), @deposit.amount)
|
||||
assert_equal(BigDecimal("12.11"), @deposit.amount)
|
||||
end
|
||||
|
||||
def test_amount_is_converted_from_float
|
||||
@deposit.amount = 12.0044
|
||||
assert_equal(BigDecimal.new("12.0044"), @deposit.amount)
|
||||
assert_equal(BigDecimal("12.0044"), @deposit.amount)
|
||||
|
||||
@deposit.amount = 12.0144
|
||||
assert_equal(BigDecimal.new("12.0144"), @deposit.amount)
|
||||
assert_equal(BigDecimal("12.0144"), @deposit.amount)
|
||||
end
|
||||
|
||||
def test_amount_is_converted_from_nil
|
||||
@deposit.amount = nil
|
||||
assert_equal(BigDecimal.new("0.00"), @deposit.amount)
|
||||
assert_equal(BigDecimal("0.00"), @deposit.amount)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,16 +5,38 @@ class DirectoTest < ActiveSupport::TestCase
|
|||
@invoice = invoices(:one)
|
||||
end
|
||||
|
||||
def test_monthly_invoices_max_range_raises_if_overlaps
|
||||
|
||||
Setting.directo_monthly_number_max = Setting.directo_monthly_number_last.to_i + Registrar.count - 1
|
||||
error_message = 'Directo counter is out of period (max allowed number is smaller than last '\
|
||||
'counternumber plus Registrar\'s count)'
|
||||
|
||||
error = assert_raises RuntimeError do
|
||||
Directo.send_monthly_invoices
|
||||
end
|
||||
|
||||
assert_equal error_message, error.message
|
||||
end
|
||||
|
||||
def test_xml_is_include_transaction_date
|
||||
@invoice.update(total: @invoice.account_activity.bank_transaction.sum)
|
||||
@invoice.account_activity.bank_transaction.update(paid_at: Time.zone.now)
|
||||
|
||||
response = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<results>
|
||||
<Result Type="0" Desc="OK" docid="1" doctype="ARVE" submit="Invoices"/>
|
||||
</results>
|
||||
XML
|
||||
|
||||
stub_request(:post, ENV['directo_invoice_url']).with do |request|
|
||||
request.body.include? 'TransactionDate'
|
||||
end
|
||||
end.to_return(status: 200, body: response)
|
||||
|
||||
assert_nothing_raised do
|
||||
Directo.send_receipts
|
||||
end
|
||||
|
||||
assert_not_empty @invoice.directo_records.first.request
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,6 +13,8 @@ class AuctionDoubleTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
class DNS::DomainNameTest < ActiveSupport::TestCase
|
||||
fixtures 'whois/records'
|
||||
|
||||
def test_available_when_not_at_auction
|
||||
domain_name = DNS::DomainName.new('auction.test')
|
||||
auctions(:one).update!(domain: 'auction.test', status: Auction.statuses[:domain_registered])
|
||||
|
|
|
@ -1,96 +0,0 @@
|
|||
# Built-in since Rails 5.1
|
||||
|
||||
module ActiveSupport
|
||||
module Testing
|
||||
module Assertions
|
||||
UNTRACKED = Object.new # :nodoc:
|
||||
|
||||
# Assertion that the result of evaluating an expression is changed before
|
||||
# and after invoking the passed in block.
|
||||
#
|
||||
# assert_changes 'Status.all_good?' do
|
||||
# post :create, params: { status: { ok: false } }
|
||||
# end
|
||||
#
|
||||
# You can pass the block as a string to be evaluated in the context of
|
||||
# the block. A lambda can be passed for the block as well.
|
||||
#
|
||||
# assert_changes -> { Status.all_good? } do
|
||||
# post :create, params: { status: { ok: false } }
|
||||
# end
|
||||
#
|
||||
# The assertion is useful to test side effects. The passed block can be
|
||||
# anything that can be converted to string with #to_s.
|
||||
#
|
||||
# assert_changes :@object do
|
||||
# @object = 42
|
||||
# end
|
||||
#
|
||||
# The keyword arguments :from and :to can be given to specify the
|
||||
# expected initial value and the expected value after the block was
|
||||
# executed.
|
||||
#
|
||||
# assert_changes :@object, from: nil, to: :foo do
|
||||
# @object = :foo
|
||||
# end
|
||||
#
|
||||
# An error message can be specified.
|
||||
#
|
||||
# assert_changes -> { Status.all_good? }, 'Expected the status to be bad' do
|
||||
# post :create, params: { status: { incident: true } }
|
||||
# end
|
||||
def assert_changes(expression, message = nil, from: UNTRACKED, to: UNTRACKED, &block)
|
||||
exp = expression.respond_to?(:call) ? expression : -> { eval(expression.to_s, block.binding) }
|
||||
|
||||
before = exp.call
|
||||
retval = yield
|
||||
|
||||
unless from == UNTRACKED
|
||||
error = "#{expression.inspect} isn't #{from.inspect}"
|
||||
error = "#{message}.\n#{error}" if message
|
||||
assert from === before, error
|
||||
end
|
||||
|
||||
after = exp.call
|
||||
|
||||
if to == UNTRACKED
|
||||
error = "#{expression.inspect} didn't changed"
|
||||
error = "#{message}.\n#{error}" if message
|
||||
assert_not_equal before, after, error
|
||||
else
|
||||
error = "#{expression.inspect} didn't change to #{to}"
|
||||
error = "#{message}.\n#{error}" if message
|
||||
assert to === after, error
|
||||
end
|
||||
|
||||
retval
|
||||
end
|
||||
|
||||
# Assertion that the result of evaluating an expression is changed before
|
||||
# and after invoking the passed in block.
|
||||
#
|
||||
# assert_no_changes 'Status.all_good?' do
|
||||
# post :create, params: { status: { ok: true } }
|
||||
# end
|
||||
#
|
||||
# An error message can be specified.
|
||||
#
|
||||
# assert_no_changes -> { Status.all_good? }, 'Expected the status to be good' do
|
||||
# post :create, params: { status: { ok: false } }
|
||||
# end
|
||||
def assert_no_changes(expression, message = nil, &block)
|
||||
exp = expression.respond_to?(:call) ? expression : -> { eval(expression.to_s, block.binding) }
|
||||
|
||||
before = exp.call
|
||||
retval = yield
|
||||
after = exp.call
|
||||
|
||||
error = "#{expression.inspect} did change to #{after}"
|
||||
error = "#{message}.\n#{error}" if message
|
||||
assert_equal before, after, error
|
||||
|
||||
retval
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -35,4 +35,15 @@ class AdminDomainsTestTest < ApplicationSystemTestCase
|
|||
assert_text 'deleteCandidate status has been removed'
|
||||
assert_no_link 'Remove deleteCandidate status'
|
||||
end
|
||||
|
||||
def test_remove_domain_status
|
||||
@domain.update!(statuses: [DomainStatus::SERVER_REGISTRANT_CHANGE_PROHIBITED])
|
||||
|
||||
visit edit_admin_domain_url(@domain)
|
||||
|
||||
click_link_or_button 'Delete'
|
||||
click_link_or_button 'Save'
|
||||
|
||||
assert_text 'Domain updated!'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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.where("id != #{domain.id}").delete_all
|
||||
end
|
||||
end
|
||||
|
||||
def run_task
|
||||
Rake::Task['data_migrations:convert_domain_delete_date'].execute
|
||||
end
|
||||
end
|
|
@ -1,43 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ArchiveOrphanedRegistrantVerificationsTest < ActiveSupport::TestCase
|
||||
def test_deletes_orphaned_registrant_verifications
|
||||
create_orphaned_registrant_verification
|
||||
|
||||
assert_difference 'RegistrantVerification.count', -1 do
|
||||
capture_io do
|
||||
run_task
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_keeps_non_orphaned_registrant_verifications_intact
|
||||
assert_no_difference 'RegistrantVerification.count' do
|
||||
capture_io do
|
||||
run_task
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_output
|
||||
create_orphaned_registrant_verification
|
||||
|
||||
assert_output "Processed: 1 out of 1\n" do
|
||||
run_task
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_orphaned_registrant_verification
|
||||
non_existent_domain_id = 55
|
||||
assert_not_includes Domain.ids, non_existent_domain_id
|
||||
|
||||
RegistrantVerification.connection.disable_referential_integrity do
|
||||
registrant_verifications(:one).update_columns(domain_id: non_existent_domain_id)
|
||||
end
|
||||
end
|
||||
|
||||
def run_task
|
||||
Rake::Task['data_migrations:delete_orphaned_registrant_verifications'].execute end
|
||||
end
|
|
@ -16,7 +16,6 @@ require 'minitest/mock'
|
|||
require 'capybara/rails'
|
||||
require 'capybara/minitest'
|
||||
require 'webmock/minitest'
|
||||
require 'support/rails5_assertions' # Remove once upgraded to Rails 5.1
|
||||
require 'support/assertions/epp_assertions'
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue