mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 16:32:04 +02:00
Move jobs from Que to ActiveJob
This commit is contained in:
parent
1d3be40e14
commit
313731232e
53 changed files with 390 additions and 157 deletions
|
@ -92,12 +92,13 @@ class EppDomainDeleteBaseTest < EppTestCase
|
|||
perform_enqueued_jobs do
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
|
||||
@domain.reload
|
||||
|
||||
assert @domain.registrant_verification_asked?
|
||||
assert @domain.pending_delete_confirmation?
|
||||
assert_emails 1
|
||||
assert_epp_response :completed_successfully_action_pending
|
||||
assert_emails 1
|
||||
end
|
||||
|
||||
def test_skips_registrant_confirmation_when_not_required
|
||||
|
|
|
@ -2,6 +2,7 @@ require 'test_helper'
|
|||
|
||||
class EppDomainUpdateBaseTest < EppTestCase
|
||||
include ActionMailer::TestHelper
|
||||
include ActiveJob::TestHelper
|
||||
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
|
@ -134,15 +135,17 @@ class EppDomainUpdateBaseTest < EppTestCase
|
|||
</epp>
|
||||
XML
|
||||
|
||||
post epp_update_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert_no_enqueued_jobs
|
||||
assert_enqueued_jobs 3 do
|
||||
post epp_update_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
@domain.reload
|
||||
|
||||
assert_epp_response :completed_successfully_action_pending
|
||||
assert_not_equal new_registrant, @domain.registrant
|
||||
assert @domain.registrant_verification_asked?
|
||||
assert_includes @domain.statuses, DomainStatus::PENDING_UPDATE
|
||||
assert_verification_and_notification_emails
|
||||
end
|
||||
|
||||
def test_domain_should_doesnt_have_pending_update_when_updated_registrant_with_same_idents_data
|
||||
|
@ -211,15 +214,17 @@ class EppDomainUpdateBaseTest < EppTestCase
|
|||
</epp>
|
||||
XML
|
||||
|
||||
post epp_update_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert_no_enqueued_jobs
|
||||
assert_enqueued_jobs 3 do
|
||||
post epp_update_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
@domain.reload
|
||||
|
||||
assert_epp_response :completed_successfully_action_pending
|
||||
assert_not_equal new_registrant, @domain.registrant
|
||||
assert @domain.registrant_verification_asked?
|
||||
assert_includes @domain.statuses, DomainStatus::PENDING_UPDATE
|
||||
assert_verification_and_notification_emails
|
||||
end
|
||||
|
||||
def test_updates_registrant_when_legaldoc_is_not_mandatory
|
||||
|
@ -247,15 +252,17 @@ class EppDomainUpdateBaseTest < EppTestCase
|
|||
</epp>
|
||||
XML
|
||||
|
||||
post epp_update_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert_no_enqueued_jobs
|
||||
assert_enqueued_jobs 3 do
|
||||
post epp_update_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
@domain.reload
|
||||
|
||||
assert_epp_response :completed_successfully_action_pending
|
||||
assert_not_equal new_registrant, @domain.registrant
|
||||
assert @domain.registrant_verification_asked?
|
||||
assert_includes @domain.statuses, DomainStatus::PENDING_UPDATE
|
||||
assert_verification_and_notification_emails
|
||||
end
|
||||
|
||||
def test_dows_not_update_registrant_when_legaldoc_is_mandatory
|
||||
|
|
45
test/jobs/active_job_queuing_test.rb
Normal file
45
test/jobs/active_job_queuing_test.rb
Normal file
|
@ -0,0 +1,45 @@
|
|||
$VERBOSE=nil
|
||||
require 'test_helper'
|
||||
|
||||
class ActiveJobQueuingTest < ActiveJob::TestCase
|
||||
|
||||
def test_job_discarded_after_error
|
||||
assert_no_enqueued_jobs
|
||||
assert_performed_jobs 1 do
|
||||
TestDiscardedJob.perform_later
|
||||
end
|
||||
assert_no_enqueued_jobs
|
||||
end
|
||||
|
||||
def test_job_retried_after_error
|
||||
assert_no_enqueued_jobs
|
||||
assert_raises StandardError do
|
||||
assert_performed_jobs 3 do
|
||||
TestRetriedJob.perform_later
|
||||
end
|
||||
end
|
||||
|
||||
assert_no_enqueued_jobs
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class TestDiscardedJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
discard_on StandardError
|
||||
|
||||
def perform
|
||||
raise StandardError
|
||||
end
|
||||
end
|
||||
|
||||
class TestRetriedJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
retry_on StandardError, wait: 2.seconds, attempts: 3
|
||||
|
||||
def perform
|
||||
raise StandardError
|
||||
end
|
||||
end
|
|
@ -38,7 +38,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
|||
end.to_return(status: 200, body: response)
|
||||
|
||||
assert_nothing_raised do
|
||||
DirectoInvoiceForwardJob.run(monthly: false, dry: false)
|
||||
DirectoInvoiceForwardJob.perform_now(monthly: false, dry: false)
|
||||
end
|
||||
|
||||
assert_not_empty @invoice.directo_records.first.request
|
||||
|
@ -52,7 +52,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
|||
Setting.directo_monthly_number_max = 30991
|
||||
|
||||
assert_raises 'RuntimeError' do
|
||||
DirectoInvoiceForwardJob.run(monthly: true, dry: false)
|
||||
DirectoInvoiceForwardJob.perform_now(monthly: true, dry: false)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -78,7 +78,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
|||
end.to_return(status: 200, body: response)
|
||||
|
||||
assert_difference 'Setting.directo_monthly_number_last' do
|
||||
DirectoInvoiceForwardJob.run(monthly: true, dry: false)
|
||||
DirectoInvoiceForwardJob.perform_now(monthly: true, dry: false)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -103,7 +103,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
|||
end.to_return(status: 200, body: response)
|
||||
|
||||
assert_difference 'Setting.directo_monthly_number_last' do
|
||||
DirectoInvoiceForwardJob.run(monthly: true, dry: false)
|
||||
DirectoInvoiceForwardJob.perform_now(monthly: true, dry: false)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -126,7 +126,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
|||
end.to_return(status: 200, body: response)
|
||||
|
||||
assert_difference 'Setting.directo_monthly_number_last' do
|
||||
DirectoInvoiceForwardJob.run(monthly: true, dry: false)
|
||||
DirectoInvoiceForwardJob.perform_now(monthly: true, dry: false)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -148,7 +148,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
|||
end.to_return(status: 200, body: response)
|
||||
|
||||
assert_difference 'Setting.directo_monthly_number_last' do
|
||||
DirectoInvoiceForwardJob.run(monthly: true, dry: false)
|
||||
DirectoInvoiceForwardJob.perform_now(monthly: true, dry: false)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -186,7 +186,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
|||
(body.include? 'StartDate') && (body.include? 'EndDate') && (body.include? 'goodnames')
|
||||
end.to_return(status: 200, body: response)
|
||||
|
||||
DirectoInvoiceForwardJob.run(monthly: true, dry: false)
|
||||
DirectoInvoiceForwardJob.perform_now(monthly: true, dry: false)
|
||||
|
||||
assert_requested first_registrar_stub
|
||||
assert_requested second_registrar_stub
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require "test_helper"
|
||||
|
||||
class DisputeStatusUpdateJobTest < ActiveSupport::TestCase
|
||||
class DisputeStatusUpdateJobTest < ActiveJob::TestCase
|
||||
setup do
|
||||
travel_to Time.zone.parse('2010-10-05')
|
||||
@logger = Rails.logger
|
||||
|
@ -8,13 +8,13 @@ class DisputeStatusUpdateJobTest < ActiveSupport::TestCase
|
|||
|
||||
def test_nothing_is_raised
|
||||
assert_nothing_raised do
|
||||
DisputeStatusUpdateJob.run(logger: @logger)
|
||||
DisputeStatusUpdateJob.perform_now(logger: @logger)
|
||||
end
|
||||
end
|
||||
|
||||
def test_whois_data_added_when_dispute_activated
|
||||
dispute = disputes(:future)
|
||||
DisputeStatusUpdateJob.run(logger: @logger)
|
||||
DisputeStatusUpdateJob.perform_now(logger: @logger)
|
||||
|
||||
whois_record = Whois::Record.find_by(name: dispute.domain_name)
|
||||
assert whois_record.present?
|
||||
|
@ -25,7 +25,7 @@ class DisputeStatusUpdateJobTest < ActiveSupport::TestCase
|
|||
dispute = disputes(:active)
|
||||
dispute.update!(starts_at: Time.zone.today - 3.years - 1.day)
|
||||
|
||||
DisputeStatusUpdateJob.run(logger: @logger)
|
||||
DisputeStatusUpdateJob.perform_now(logger: @logger)
|
||||
dispute.reload
|
||||
|
||||
assert dispute.closed
|
||||
|
@ -37,7 +37,9 @@ class DisputeStatusUpdateJobTest < ActiveSupport::TestCase
|
|||
def test_registered_domain_whois_data_is_added
|
||||
Dispute.create(domain_name: 'shop.test', starts_at: '2010-07-05')
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
DisputeStatusUpdateJob.run(logger: @logger)
|
||||
perform_enqueued_jobs do
|
||||
DisputeStatusUpdateJob.perform_now(logger: @logger)
|
||||
end
|
||||
|
||||
whois_record = Whois::Record.find_by(name: 'shop.test')
|
||||
assert_includes whois_record.json['status'], 'disputed'
|
||||
|
@ -53,7 +55,9 @@ class DisputeStatusUpdateJobTest < ActiveSupport::TestCase
|
|||
force_delete_date: nil)
|
||||
|
||||
# Dispute status is added automatically if starts_at is not in future
|
||||
Dispute.create(domain_name: 'shop.test', starts_at: Time.zone.parse('2010-07-05'))
|
||||
perform_enqueued_jobs do
|
||||
Dispute.create(domain_name: 'shop.test', starts_at: Time.zone.parse('2010-07-05'))
|
||||
end
|
||||
domain.reload
|
||||
|
||||
whois_record = Whois::Record.find_by(name: 'shop.test')
|
||||
|
@ -62,7 +66,9 @@ class DisputeStatusUpdateJobTest < ActiveSupport::TestCase
|
|||
# Dispute status is removed night time day after it's ended
|
||||
travel_to Time.zone.parse('2010-07-05') + 3.years + 1.day
|
||||
|
||||
DisputeStatusUpdateJob.run(logger: @logger)
|
||||
perform_enqueued_jobs do
|
||||
DisputeStatusUpdateJob.perform_now(logger: @logger)
|
||||
end
|
||||
|
||||
whois_record.reload
|
||||
assert_not whois_record.json['status'].include? 'disputed'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegenerateSubzoneWhoisesJobTest < ActiveSupport::TestCase
|
||||
class RegenerateSubzoneWhoisesJobTest < ActiveJob::TestCase
|
||||
def test_regenerates_whois_data_only_for_subzones
|
||||
subzone = dns_zones(:one).dup
|
||||
subzone.origin = 'subzone.test'
|
||||
|
@ -11,7 +11,9 @@ class RegenerateSubzoneWhoisesJobTest < ActiveSupport::TestCase
|
|||
assert_nil Whois::Record.find_by(name: subzone.origin)
|
||||
assert_nil Whois::Record.find_by(name: dns_zones(:one).origin)
|
||||
|
||||
RegenerateSubzoneWhoisesJob.run
|
||||
perform_enqueued_jobs do
|
||||
RegenerateSubzoneWhoisesJob.perform_now
|
||||
end
|
||||
record = Whois::Record.find_by(name: subzone.origin)
|
||||
assert record
|
||||
assert record.json['dnssec_keys'].is_a?(Array)
|
||||
|
|
|
@ -11,8 +11,8 @@ class RegistrantChangeConfirmEmailJobTest < ActiveSupport::TestCase
|
|||
domain_id = domains(:shop).id
|
||||
new_registrant_id = contacts(:william).id
|
||||
|
||||
RegistrantChangeConfirmEmailJob.enqueue(domain_id, new_registrant_id)
|
||||
RegistrantChangeConfirmEmailJob.perform_now(domain_id, new_registrant_id)
|
||||
|
||||
assert_emails 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
24
test/jobs/registrant_change_expired_email_job_test.rb
Normal file
24
test/jobs/registrant_change_expired_email_job_test.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrantChangeExpiredEmailJobTest < ActiveJob::TestCase
|
||||
include ActionMailer::TestHelper
|
||||
|
||||
setup do
|
||||
ActionMailer::Base.deliveries.clear
|
||||
end
|
||||
|
||||
def test_delivers_email
|
||||
domain = domains(:shop)
|
||||
domain.update!(pending_json: {new_registrant_email: 'aaa@bbb.com'})
|
||||
domain_id = domain.id
|
||||
|
||||
assert_performed_jobs 1 do
|
||||
perform_enqueued_jobs do
|
||||
RegistrantChangeExpiredEmailJob.perform_later(domain_id)
|
||||
end
|
||||
end
|
||||
|
||||
assert_emails 1
|
||||
end
|
||||
|
||||
end
|
|
@ -11,8 +11,8 @@ class RegistrantChangeNoticeEmailJobTest < ActiveSupport::TestCase
|
|||
domain_id = domains(:shop).id
|
||||
new_registrant_id = contacts(:william).id
|
||||
|
||||
RegistrantChangeNoticeEmailJob.enqueue(domain_id, new_registrant_id)
|
||||
RegistrantChangeNoticeEmailJob.perform_now(domain_id, new_registrant_id)
|
||||
|
||||
assert_emails 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,43 +1,22 @@
|
|||
require 'test_helper'
|
||||
|
||||
class SendEInvoiceJobTest < ActiveSupport::TestCase
|
||||
class SendEInvoiceJobTest < ActiveJob::TestCase
|
||||
|
||||
def teardown
|
||||
EInvoice.provider = EInvoice::Providers::TestProvider.new
|
||||
EInvoice::Providers::TestProvider.deliveries.clear
|
||||
end
|
||||
|
||||
def test_if_invoice_is_sended
|
||||
def test_if_invoice_is_sent
|
||||
@invoice = invoices(:one)
|
||||
@invoice.account_activity.destroy
|
||||
EInvoice.provider = EInvoice::Providers::TestProvider.new
|
||||
EInvoice::Providers::TestProvider.deliveries.clear
|
||||
|
||||
assert_nothing_raised do
|
||||
SendEInvoiceJob.enqueue(@invoice.id, true)
|
||||
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, true)
|
||||
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, true)
|
||||
perform_enqueued_jobs do
|
||||
SendEInvoiceJob.perform_now(@invoice.id, true)
|
||||
end
|
||||
end
|
||||
@invoice.reload
|
||||
|
||||
|
|
28
test/jobs/update_whois_record_job_test.rb
Normal file
28
test/jobs/update_whois_record_job_test.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
require 'test_helper'
|
||||
|
||||
class SendEInvoiceJobTest < ActiveJob::TestCase
|
||||
|
||||
def test_job_is_updating_domains
|
||||
domain_names = Domain.find_in_batches.first.map(&:name)
|
||||
assert_domains_processed_by_task(domain_names, 'domain')
|
||||
end
|
||||
|
||||
def test_job_is_updating_blocked_domains
|
||||
domain_names = BlockedDomain.find_in_batches.first.map(&:name)
|
||||
assert_domains_processed_by_task(domain_names, 'blocked')
|
||||
end
|
||||
|
||||
def test_job_is_updating_reserved_domains
|
||||
domain_names = ReservedDomain.find_in_batches.first.map(&:name)
|
||||
assert_domains_processed_by_task(domain_names, 'reserved')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assert_domains_processed_by_task(domain_names, type)
|
||||
Rake::Task['whois:regenerate'].execute
|
||||
|
||||
perform_enqueued_jobs
|
||||
assert_performed_with(job: UpdateWhoisRecordJob, args: [domain_names, type])
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require "test_helper"
|
||||
|
||||
class VerifyEmailsJobTest < ActiveSupport::TestCase
|
||||
class VerifyEmailsJobTest < ActiveJob::TestCase
|
||||
def setup
|
||||
@contact = contacts(:john)
|
||||
@invalid_contact = contacts(:invalid_email)
|
||||
|
@ -33,7 +33,9 @@ class VerifyEmailsJobTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_job_checks_if_email_valid
|
||||
VerifyEmailsJob.run(@contact_verification.id)
|
||||
perform_enqueued_jobs do
|
||||
VerifyEmailsJob.perform_now(@contact_verification.id)
|
||||
end
|
||||
@contact_verification.reload
|
||||
|
||||
assert @contact_verification.success
|
||||
|
@ -44,14 +46,18 @@ class VerifyEmailsJobTest < ActiveSupport::TestCase
|
|||
@contact_verification.update(success: true, verified_at: old_verified_at)
|
||||
assert @contact_verification.recently_verified?
|
||||
|
||||
VerifyEmailsJob.run(@contact_verification.id)
|
||||
perform_enqueued_jobs do
|
||||
VerifyEmailsJob.perform_now(@contact_verification.id)
|
||||
end
|
||||
@contact_verification.reload
|
||||
|
||||
assert_in_delta @contact_verification.verified_at.to_i, old_verified_at.to_i, 1
|
||||
end
|
||||
|
||||
def test_job_checks_if_email_invalid
|
||||
VerifyEmailsJob.run(@invalid_contact_verification.id)
|
||||
perform_enqueued_jobs do
|
||||
VerifyEmailsJob.perform_now(@invalid_contact_verification.id)
|
||||
end
|
||||
@contact_verification.reload
|
||||
|
||||
refute @contact_verification.success
|
||||
|
|
|
@ -37,6 +37,8 @@ class RegistrantChangeMailerPreview < ActionMailer::Preview
|
|||
def expired
|
||||
RegistrantChangeMailer.expired(domain: @domain,
|
||||
registrar: @domain.registrar,
|
||||
registrant: @domain.registrant)
|
||||
registrant: @domain.registrant,
|
||||
send_to: [@domain.new_registrant_email,
|
||||
@domain.registrant.email])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ContactTest < ActiveSupport::TestCase
|
||||
class ContactTest < ActiveJob::TestCase
|
||||
setup do
|
||||
@contact = contacts(:john)
|
||||
@old_validation_type = Truemail.configure.default_validation_type
|
||||
|
@ -336,7 +336,9 @@ class ContactTest < ActiveSupport::TestCase
|
|||
@contact.name = 'SomeReallyWeirdRandomTestName'
|
||||
domain = @contact.registrant_domains.first
|
||||
|
||||
@contact.save!
|
||||
perform_enqueued_jobs do
|
||||
@contact.save!
|
||||
end
|
||||
|
||||
assert_equal domain.whois_record.try(:json).try(:[], 'registrant'), @contact.name
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DNS::ZoneTest < ActiveSupport::TestCase
|
||||
class DNS::ZoneTest < ActiveJob::TestCase
|
||||
def test_valid_zone_fixture_is_valid
|
||||
assert valid_zone.valid?, proc { valid_zone.errors.full_messages }
|
||||
end
|
||||
|
@ -134,7 +134,9 @@ class DNS::ZoneTest < ActiveSupport::TestCase
|
|||
subzone = dns_zones(:one).dup
|
||||
|
||||
subzone.origin = 'sub.zone'
|
||||
subzone.save
|
||||
perform_enqueued_jobs do
|
||||
subzone.save
|
||||
end
|
||||
|
||||
whois_record = Whois::Record.find_by(name: subzone.origin)
|
||||
assert whois_record.present?
|
||||
|
@ -144,7 +146,9 @@ class DNS::ZoneTest < ActiveSupport::TestCase
|
|||
subzone = dns_zones(:one).dup
|
||||
|
||||
subzone.origin = 'sub.zone'
|
||||
subzone.save
|
||||
perform_enqueued_jobs do
|
||||
subzone.save
|
||||
end
|
||||
|
||||
whois_record = Whois::Record.find_by(name: subzone.origin)
|
||||
assert whois_record.present?
|
||||
|
@ -170,11 +174,15 @@ class DNS::ZoneTest < ActiveSupport::TestCase
|
|||
subzone = dns_zones(:one).dup
|
||||
|
||||
subzone.origin = 'sub.zone'
|
||||
subzone.save
|
||||
perform_enqueued_jobs do
|
||||
subzone.save
|
||||
end
|
||||
|
||||
assert Whois::Record.find_by(name: subzone.origin).present?
|
||||
|
||||
subzone.destroy
|
||||
perform_enqueued_jobs do
|
||||
subzone.destroy
|
||||
end
|
||||
assert_nil Whois::Record.find_by(name: subzone.origin)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DomainReleasableAuctionableTest < ActiveSupport::TestCase
|
||||
class DomainReleasableAuctionableTest < ActiveJob::TestCase
|
||||
# Needed for `test_updates_whois` test because of `after_commit :update_whois_record` in Domain
|
||||
self.use_transactional_tests = false
|
||||
|
||||
|
@ -65,7 +65,9 @@ class DomainReleasableAuctionableTest < ActiveSupport::TestCase
|
|||
travel_to Time.zone.parse('2010-07-05')
|
||||
old_whois = @domain.whois_record
|
||||
|
||||
Domain.release_domains
|
||||
perform_enqueued_jobs do
|
||||
Domain.release_domains
|
||||
end
|
||||
|
||||
assert_raises ActiveRecord::RecordNotFound do
|
||||
old_whois.reload
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DomainReleasableDiscardableTest < ActiveSupport::TestCase
|
||||
include ActiveJob::TestHelper
|
||||
|
||||
setup do
|
||||
ActiveJob::Base.queue_adapter = :test
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
||||
|
@ -64,16 +67,18 @@ class DomainReleasableDiscardableTest < ActiveSupport::TestCase
|
|||
travel_to Time.zone.parse('2010-07-05')
|
||||
|
||||
@domain.update_columns(delete_date: '2010-07-05')
|
||||
Domain.release_domains
|
||||
|
||||
assert_enqueued_with(job: DomainDeleteJob) do
|
||||
Domain.release_domains
|
||||
end
|
||||
|
||||
other_domain = domains(:airport)
|
||||
other_domain.update_columns(delete_date: '2010-07-05')
|
||||
Domain.release_domains
|
||||
assert_enqueued_with(job: DomainDeleteJob) do
|
||||
Domain.release_domains
|
||||
end
|
||||
|
||||
background_job = QueJob.find_by("args->>0 = '#{@domain.id}'", job_class: DomainDeleteJob.name)
|
||||
other_background_job = QueJob.find_by("args->>0 = '#{other_domain.id}'",
|
||||
job_class: DomainDeleteJob.name)
|
||||
assert_not_equal background_job.run_at, other_background_job.run_at
|
||||
assert_not other_domain.deletion_time == @domain.deletion_time
|
||||
end
|
||||
|
||||
def test_discarding_a_domain_bypasses_validation
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarTest < ActiveSupport::TestCase
|
||||
class RegistrarTest < ActiveJob::TestCase
|
||||
setup do
|
||||
@registrar = registrars(:bestnames)
|
||||
@original_default_language = Setting.default_language
|
||||
|
@ -213,7 +213,9 @@ class RegistrarTest < ActiveSupport::TestCase
|
|||
def test_issues_e_invoice_along_with_invoice
|
||||
EInvoice::Providers::TestProvider.deliveries.clear
|
||||
|
||||
@registrar.issue_prepayment_invoice(100)
|
||||
perform_enqueued_jobs do
|
||||
@registrar.issue_prepayment_invoice(100)
|
||||
end
|
||||
|
||||
assert_equal 1, EInvoice::Providers::TestProvider.deliveries.count
|
||||
end
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class DomainDeleteConfirmsTest < ApplicationSystemTestCase
|
||||
include ActionMailer::TestHelper
|
||||
setup do
|
||||
@user = users(:registrant)
|
||||
sign_in @user
|
||||
|
||||
@domain = domains(:shop)
|
||||
@domain.registrant_verification_asked!('<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<epp></epp>', @user.id)
|
||||
@domain.pending_delete!
|
||||
end
|
||||
|
||||
def test_enqueues_approve_job_after_verification
|
||||
visit registrant_domain_delete_confirm_url(@domain.id, token: @domain.registrant_verification_token)
|
||||
|
||||
click_on 'Confirm domain delete'
|
||||
|
||||
assert_text 'Domain registrant change has successfully received.'
|
||||
|
||||
assert_enqueued_jobs 1, only: DomainDeleteConfirmJob
|
||||
end
|
||||
|
||||
def test_enqueues_reject_job_after_verification
|
||||
visit registrant_domain_delete_confirm_url(@domain.id, token: @domain.registrant_verification_token)
|
||||
|
||||
click_on 'Reject domain delete'
|
||||
|
||||
assert_text 'Domain registrant change has been rejected successfully.'
|
||||
|
||||
assert_enqueued_jobs 1, only: DomainDeleteConfirmJob
|
||||
end
|
||||
|
||||
def test_saves_whodunnit_info_after_verifivation
|
||||
visit registrant_domain_delete_confirm_url(@domain.id, token: @domain.registrant_verification_token)
|
||||
token = @domain.registrant_verification_token
|
||||
click_on 'Confirm domain delete'
|
||||
assert_text 'Domain registrant change has successfully received.'
|
||||
|
||||
refute RegistrantVerification.find_by(verification_token:token).updator_str.empty?
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class VerifyEmailTaskTest < ActiveSupport::TestCase
|
||||
class VerifyEmailTaskTest < ActiveJob::TestCase
|
||||
|
||||
def setup
|
||||
@contact = contacts(:john)
|
||||
|
@ -54,10 +54,14 @@ class VerifyEmailTaskTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def run_task
|
||||
Rake::Task['verify_email:all_domains'].execute
|
||||
perform_enqueued_jobs do
|
||||
Rake::Task['verify_email:all_domains'].execute
|
||||
end
|
||||
end
|
||||
|
||||
def run_single_domain_task(domain)
|
||||
Rake::Task["verify_email:domain"].invoke(domain)
|
||||
perform_enqueued_jobs do
|
||||
Rake::Task["verify_email:domain"].invoke(domain)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,6 +27,8 @@ require 'rake'
|
|||
Rake::Task.clear
|
||||
Rails.application.load_tasks
|
||||
|
||||
ActiveJob::Base.queue_adapter = :test
|
||||
|
||||
class CompanyRegisterClientStub
|
||||
Company = Struct.new(:registration_number, :company_name)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue