mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 19:20:37 +02:00
parent
ed27152bb1
commit
4ddbb08e80
19 changed files with 111 additions and 271 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.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