mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 11:16:00 +02:00
Merge remote-tracking branch 'origin/master' into 509-directo-to-gem
This commit is contained in:
commit
86889b6432
39 changed files with 298 additions and 280 deletions
|
@ -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
|
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue