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