mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 21:25:39 +02:00
Merge branch 'master' into refactor-messages
# Conflicts: # db/structure.sql
This commit is contained in:
commit
aff5b68a2f
29 changed files with 297 additions and 93 deletions
|
@ -1,7 +1,7 @@
|
|||
module Admin
|
||||
class DomainsController < BaseController
|
||||
load_and_authorize_resource
|
||||
before_action :set_domain, only: [:show, :edit, :update, :zonefile]
|
||||
before_action :set_domain, only: %i[show edit update keep]
|
||||
authorize_resource
|
||||
helper_method :force_delete_templates
|
||||
|
||||
def index
|
||||
|
@ -33,7 +33,8 @@ module Admin
|
|||
end
|
||||
|
||||
def show
|
||||
@domain.valid?
|
||||
# Validation is needed to warn users
|
||||
@domain.validate
|
||||
end
|
||||
|
||||
def edit
|
||||
|
@ -60,6 +61,11 @@ module Admin
|
|||
@versions = @domain.versions
|
||||
end
|
||||
|
||||
def keep
|
||||
@domain.keep
|
||||
redirect_to edit_admin_domain_url(@domain), notice: t('.kept')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_domain
|
||||
|
|
|
@ -1,16 +1,25 @@
|
|||
module Concerns::Domain::Deletable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
alias_attribute :delete_time, :delete_at
|
||||
private
|
||||
|
||||
def delete_later
|
||||
deletion_time = Time.zone.at(rand(deletion_time_span))
|
||||
DomainDeleteJob.enqueue(id, run_at: deletion_time, priority: 1)
|
||||
logger.info "Domain #{name} is scheduled to be deleted around #{deletion_time}"
|
||||
end
|
||||
|
||||
def discard
|
||||
statuses << DomainStatus::DELETE_CANDIDATE
|
||||
save
|
||||
def do_not_delete_later
|
||||
# Que job can be manually deleted in admin area UI
|
||||
QueJob.find_by("args->>0 = '#{id}'", job_class: DomainDeleteJob.name)&.destroy
|
||||
end
|
||||
|
||||
def discarded?
|
||||
statuses.include?(DomainStatus::DELETE_CANDIDATE)
|
||||
def deletion_time_span
|
||||
range_params = [Time.zone.now.to_i, deletion_deadline.to_i].sort
|
||||
Range.new(*range_params)
|
||||
end
|
||||
end
|
||||
|
||||
def deletion_deadline
|
||||
delete_at + 24.hours
|
||||
end
|
||||
end
|
40
app/models/concerns/domain/discardable.rb
Normal file
40
app/models/concerns/domain/discardable.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
module Concerns::Domain::Discardable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
||||
def discard_domains
|
||||
domains = where('delete_at < ? AND ? != ALL(coalesce(statuses, array[]::varchar[])) AND' \
|
||||
' ? != ALL(COALESCE(statuses, array[]::varchar[]))',
|
||||
Time.zone.now,
|
||||
DomainStatus::SERVER_DELETE_PROHIBITED,
|
||||
DomainStatus::DELETE_CANDIDATE)
|
||||
|
||||
domains.each do |domain|
|
||||
domain.discard
|
||||
yield domain if block_given?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def discard
|
||||
raise 'Domain is already discarded' if discarded?
|
||||
|
||||
statuses << DomainStatus::DELETE_CANDIDATE
|
||||
transaction do
|
||||
save(validate: false)
|
||||
delete_later
|
||||
end
|
||||
end
|
||||
|
||||
def keep
|
||||
statuses.delete(DomainStatus::DELETE_CANDIDATE)
|
||||
transaction do
|
||||
save(validate: false)
|
||||
do_not_delete_later
|
||||
end
|
||||
end
|
||||
|
||||
def discarded?
|
||||
statuses.include?(DomainStatus::DELETE_CANDIDATE)
|
||||
end
|
||||
end
|
|
@ -4,6 +4,7 @@ class Domain < ActiveRecord::Base
|
|||
include Concerns::Domain::Expirable
|
||||
include Concerns::Domain::Activatable
|
||||
include Concerns::Domain::ForceDelete
|
||||
include Concerns::Domain::Discardable
|
||||
include Concerns::Domain::Deletable
|
||||
include Concerns::Domain::Transferable
|
||||
|
||||
|
@ -249,13 +250,6 @@ class Domain < ActiveRecord::Base
|
|||
true
|
||||
end
|
||||
|
||||
def delete_candidateable?
|
||||
return false if delete_at > Time.zone.now
|
||||
return false if statuses.include?(DomainStatus::DELETE_CANDIDATE)
|
||||
return false if statuses.include?(DomainStatus::SERVER_DELETE_PROHIBITED)
|
||||
true
|
||||
end
|
||||
|
||||
def renewable?
|
||||
if Setting.days_to_renew_domain_before_expire != 0
|
||||
# if you can renew domain at days_to_renew before domain expiration
|
||||
|
@ -613,10 +607,6 @@ class Domain < ActiveRecord::Base
|
|||
where("#{attribute_alias(:outzone_time)} < ?", Time.zone.now)
|
||||
end
|
||||
|
||||
def self.delete_candidates
|
||||
where("#{attribute_alias(:delete_time)} < ?", Time.zone.now)
|
||||
end
|
||||
|
||||
def self.uses_zone?(zone)
|
||||
exists?(["name ILIKE ?", "%.#{zone.origin}"])
|
||||
end
|
||||
|
|
|
@ -84,22 +84,6 @@ class DomainCron
|
|||
|
||||
c = 0
|
||||
|
||||
domains = Domain.delete_candidates
|
||||
|
||||
domains.each do |domain|
|
||||
next unless domain.delete_candidateable?
|
||||
|
||||
domain.statuses << DomainStatus::DELETE_CANDIDATE
|
||||
|
||||
# If domain successfully saved, add it to delete schedule
|
||||
if domain.save(validate: false)
|
||||
::PaperTrail.whodunnit = "cron - #{__method__}"
|
||||
DomainDeleteJob.enqueue(domain.id, run_at: rand(((24*60) - (DateTime.now.hour * 60 + DateTime.now.minute))).minutes.from_now)
|
||||
STDOUT << "#{Time.zone.now.utc} DomainCron.destroy_delete_candidates: job added by deleteCandidate status ##{domain.id} (#{domain.name})\n" unless Rails.env.test?
|
||||
c += 1
|
||||
end
|
||||
end
|
||||
|
||||
Domain.where('force_delete_at <= ?', Time.zone.now.end_of_day.utc).each do |x|
|
||||
DomainDeleteJob.enqueue(x.id, run_at: rand(((24*60) - (DateTime.now.hour * 60 + DateTime.now.minute))).minutes.from_now)
|
||||
STDOUT << "#{Time.zone.now.utc} DomainCron.destroy_delete_candidates: job added by force delete time ##{x.id} (#{x.name})\n" unless Rails.env.test?
|
||||
|
|
|
@ -153,13 +153,11 @@ class DomainStatus < ActiveRecord::Base
|
|||
[
|
||||
['Hold', SERVER_HOLD],
|
||||
['ManualInzone', SERVER_MANUAL_INZONE],
|
||||
# [''],
|
||||
['RenewProhibited', SERVER_RENEW_PROHIBITED],
|
||||
['TransferProhibited', SERVER_TRANSFER_PROHIBITED],
|
||||
['RegistrantChangeProhibited', SERVER_REGISTRANT_CHANGE_PROHIBITED],
|
||||
['AdminChangeProhibited', SERVER_ADMIN_CHANGE_PROHIBITED],
|
||||
['TechChangeProhibited', SERVER_TECH_CHANGE_PROHIBITED],
|
||||
# [''],
|
||||
['UpdateProhibited', SERVER_UPDATE_PROHIBITED],
|
||||
['DeleteProhibited', SERVER_DELETE_PROHIBITED]
|
||||
]
|
||||
|
@ -171,11 +169,11 @@ class DomainStatus < ActiveRecord::Base
|
|||
INACTIVE,
|
||||
FORCE_DELETE,
|
||||
PENDING_CREATE,
|
||||
#PENDING_DELETE,
|
||||
PENDING_RENEW,
|
||||
PENDING_TRANSFER,
|
||||
PENDING_UPDATE,
|
||||
PENDING_DELETE_CONFIRMATION
|
||||
PENDING_DELETE_CONFIRMATION,
|
||||
DELETE_CANDIDATE,
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
4
app/models/que_job.rb
Normal file
4
app/models/que_job.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
# To be able to remove existing jobs
|
||||
class QueJob < ActiveRecord::Base
|
||||
self.primary_key = 'job_id'
|
||||
end
|
|
@ -30,7 +30,7 @@ class DomainPresenter
|
|||
end
|
||||
|
||||
def delete_date
|
||||
view.l(domain.delete_time, format: :date) if domain.delete_time
|
||||
view.l(domain.delete_at, format: :date) if domain.delete_at
|
||||
end
|
||||
|
||||
def force_delete_date
|
||||
|
@ -59,6 +59,15 @@ class DomainPresenter
|
|||
end
|
||||
end
|
||||
|
||||
def keep_btn
|
||||
return unless domain.discarded?
|
||||
|
||||
view.link_to view.t('admin.domains.edit.keep_btn'), view.keep_admin_domain_path(@domain),
|
||||
method: :patch,
|
||||
data: { confirm: view.t('admin.domains.edit.keep_btn_confirm') },
|
||||
class: 'btn btn-default'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def schedule_force_delete_btn
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
<div class="col-sm-8 text-right">
|
||||
<%= link_to t('.add_new_status_btn'), '#', class: 'btn btn-primary js-add-status' %>
|
||||
<%= domain.keep_btn %>
|
||||
<%= domain.force_delete_toggle_btn %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -15,6 +15,11 @@ en:
|
|||
edit:
|
||||
header: "Edit: %{domain}"
|
||||
add_new_status_btn: Add new status
|
||||
keep_btn: Remove deleteCandidate status
|
||||
keep_btn_confirm: Are you sure you want to remove deleteCandidate status?
|
||||
|
||||
keep:
|
||||
kept: deleteCandidate status has been removed
|
||||
|
||||
force_delete_dialog:
|
||||
title: Force delete
|
||||
|
|
|
@ -190,11 +190,15 @@ Rails.application.routes.draw do
|
|||
match 'forward', via: [:post, :get]
|
||||
end
|
||||
|
||||
resources :domains do
|
||||
resources :domains, except: %i[new create destroy] do
|
||||
resources :domain_versions, controller: 'domains', action: 'versions'
|
||||
resources :pending_updates
|
||||
resources :pending_deletes
|
||||
resource :force_delete, controller: 'domains/force_delete', only: %i[create destroy]
|
||||
|
||||
member do
|
||||
patch :keep
|
||||
end
|
||||
end
|
||||
|
||||
resources :domain_versions do
|
||||
|
|
|
@ -57,6 +57,10 @@ if @cron_group == 'registry'
|
|||
every :day, at: '19:00pm' do
|
||||
runner 'Directo.send_receipts'
|
||||
end if @environment == 'production'
|
||||
|
||||
every 42.minutes do
|
||||
rake 'domain:discard'
|
||||
end
|
||||
end
|
||||
|
||||
every 10.minutes do
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class ChangeContactsEmailToNotNull < ActiveRecord::Migration
|
||||
def change
|
||||
change_column_null :contacts, :email, false
|
||||
end
|
||||
end
|
|
@ -613,7 +613,7 @@ CREATE TABLE public.contacts (
|
|||
id integer NOT NULL,
|
||||
code character varying NOT NULL,
|
||||
phone character varying,
|
||||
email character varying,
|
||||
email character varying NOT NULL,
|
||||
fax character varying,
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone,
|
||||
|
@ -4762,6 +4762,8 @@ INSERT INTO schema_migrations (version) VALUES ('20180613045614');
|
|||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20180713154915');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20180816123540');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20180823161237');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20180823163548');
|
||||
|
|
13
lib/tasks/domain.rake
Normal file
13
lib/tasks/domain.rake
Normal file
|
@ -0,0 +1,13 @@
|
|||
namespace :domain do
|
||||
desc 'Discard domains'
|
||||
task discard: :environment do
|
||||
domain_count = 0
|
||||
|
||||
Domain.discard_domains do |domain|
|
||||
puts "#{domain} is discarded"
|
||||
domain_count = domain_count + 1
|
||||
end
|
||||
|
||||
puts "Discarded total: #{domain_count}"
|
||||
end
|
||||
end
|
|
@ -840,22 +840,6 @@ RSpec.describe Domain do
|
|||
end
|
||||
end
|
||||
|
||||
describe '::delete_candidates', db: true do
|
||||
before :example do
|
||||
travel_to Time.zone.parse('05.07.2010 00:00')
|
||||
|
||||
create(:zone, origin: 'ee')
|
||||
|
||||
create(:domain, id: 1, delete_time: Time.zone.parse('04.07.2010 23:59'))
|
||||
create(:domain, id: 2, delete_time: Time.zone.parse('05.07.2010 00:00'))
|
||||
create(:domain, id: 3, delete_time: Time.zone.parse('05.07.2010 00:01'))
|
||||
end
|
||||
|
||||
it 'returns domains with delete time in the past' do
|
||||
expect(described_class.delete_candidates.ids).to eq([1])
|
||||
end
|
||||
end
|
||||
|
||||
describe '::uses_zone?', db: true do
|
||||
let!(:zone) { create(:zone, origin: 'domain.tld') }
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ RSpec.describe DomainPresenter do
|
|||
subject(:delete_date) { presenter.delete_date }
|
||||
|
||||
context 'when present' do
|
||||
let(:domain) { instance_double(Domain, delete_time: '05.07.2010') }
|
||||
let(:domain) { instance_double(Domain, delete_at: '05.07.2010') }
|
||||
|
||||
it 'returns localized date' do
|
||||
expect(view).to receive(:l).with('05.07.2010', format: :date).and_return('delete date')
|
||||
|
@ -53,7 +53,7 @@ RSpec.describe DomainPresenter do
|
|||
end
|
||||
|
||||
context 'when absent' do
|
||||
let(:domain) { instance_double(Domain, delete_time: nil) }
|
||||
let(:domain) { instance_double(Domain, delete_at: nil) }
|
||||
|
||||
specify { expect(delete_date).to be_nil }
|
||||
end
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainDeleteTest < ApplicationIntegrationTest
|
||||
def setup
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
||||
def test_bypasses_domain_and_registrant_and_contacts_validation
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
@ -27,7 +31,9 @@ class EppDomainDeleteTest < ApplicationIntegrationTest
|
|||
end
|
||||
|
||||
def test_discarded_domain_cannot_be_deleted
|
||||
domains(:shop).discard
|
||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||
@domain.delete_at = Time.zone.parse('2010-07-05 10:00')
|
||||
@domain.discard
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
@ -51,5 +57,6 @@ class EppDomainDeleteTest < ApplicationIntegrationTest
|
|||
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
assert_equal '2105', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
travel_back
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainUpdateTest < ApplicationIntegrationTest
|
||||
def setup
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
||||
def test_update_domain
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
@ -21,13 +25,16 @@ class EppDomainUpdateTest < ApplicationIntegrationTest
|
|||
XML
|
||||
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
assert_equal 'f0ff7d17b0', domains(:shop).transfer_code
|
||||
@domain.reload
|
||||
assert_equal 'f0ff7d17b0', @domain.transfer_code
|
||||
assert_equal '1000', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
||||
end
|
||||
|
||||
def test_discarded_domain_cannot_be_updated
|
||||
domains(:shop).discard
|
||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||
@domain.delete_at = Time.zone.parse('2010-07-05 10:00')
|
||||
@domain.discard
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
@ -44,5 +51,6 @@ class EppDomainUpdateTest < ApplicationIntegrationTest
|
|||
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
assert_equal '2105', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
travel_back
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainTransferRequestTest < ApplicationIntegrationTest
|
||||
setup do
|
||||
def setup
|
||||
@domain = domains(:shop)
|
||||
@new_registrar = registrars(:goodnames)
|
||||
@original_transfer_wait_time = Setting.transfer_wait_time
|
||||
Setting.transfer_wait_time = 0
|
||||
end
|
||||
|
||||
def teardown
|
||||
Setting.transfer_wait_time = @original_transfer_wait_time
|
||||
end
|
||||
|
||||
def test_transfers_domain_at_once
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
assert_equal '1000', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
|
@ -75,14 +80,17 @@ class EppDomainTransferRequestTest < ApplicationIntegrationTest
|
|||
assert_equal '2304', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
end
|
||||
|
||||
def test_discarded_domain
|
||||
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
def test_discarded_domain_cannot_be_transferred
|
||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||
@domain.delete_at = Time.zone.parse('2010-07-05 10:00')
|
||||
@domain.discard
|
||||
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
@domain.reload
|
||||
|
||||
assert_equal registrars(:bestnames), @domain.registrar
|
||||
assert_equal '2105', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
travel_back
|
||||
end
|
||||
|
||||
def test_same_registrar
|
||||
|
|
51
test/integration/tasks/discard_domain_test.rb
Normal file
51
test/integration/tasks/discard_domain_test.rb
Normal file
|
@ -0,0 +1,51 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DiscardDomainTaskTest < TaskTestCase
|
||||
setup do
|
||||
travel_to Time.zone.parse('2010-07-05 08:00')
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
||||
def test_discard_domains_with_past_delete_at
|
||||
@domain.update!(delete_at: Time.zone.parse('2010-07-05 07:59'))
|
||||
Rake::Task['domain:discard'].execute
|
||||
@domain.reload
|
||||
assert @domain.discarded?
|
||||
end
|
||||
|
||||
def test_ignore_domains_with_delete_at_in_the_future_or_now
|
||||
@domain.update!(delete_at: Time.zone.parse('2010-07-05 08:00'))
|
||||
Rake::Task['domain:discard'].execute
|
||||
@domain.reload
|
||||
refute @domain.discarded?
|
||||
end
|
||||
|
||||
def test_ignore_already_discarded_domains
|
||||
@domain.update!(delete_at: Time.zone.parse('2010-07-05 07:59'))
|
||||
@domain.discard
|
||||
|
||||
job_count = lambda do
|
||||
QueJob.where("args->>0 = '#{@domain.id}'", job_class: DomainDeleteJob.name).count
|
||||
end
|
||||
|
||||
assert_no_difference job_count, 'A domain should not be discarded again' do
|
||||
Rake::Task['domain:discard'].execute
|
||||
end
|
||||
end
|
||||
|
||||
def test_ignore_domains_with_server_delete_prohibited_status
|
||||
@domain.update!(delete_at: Time.zone.parse('2010-07-05 07:59'),
|
||||
statuses: [DomainStatus::SERVER_DELETE_PROHIBITED])
|
||||
Rake::Task['domain:discard'].execute
|
||||
@domain.reload
|
||||
refute @domain.discarded?
|
||||
end
|
||||
|
||||
def test_show_results
|
||||
@domain.update!(delete_at: Time.zone.parse('2010-07-05 07:59'))
|
||||
$stdout = StringIO.new
|
||||
|
||||
Rake::Task['domain:discard'].execute
|
||||
assert_equal "shop.test is discarded\nDiscarded total: 1\n", $stdout.string
|
||||
end
|
||||
end
|
|
@ -1,14 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DomainDeletableTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
||||
def test_discard
|
||||
refute @domain.discarded?
|
||||
@domain.discard
|
||||
@domain.reload
|
||||
assert @domain.discarded?
|
||||
end
|
||||
end
|
63
test/models/domain/discardable_test.rb
Normal file
63
test/models/domain/discardable_test.rb
Normal file
|
@ -0,0 +1,63 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DomainDiscardableTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||
@domain = domains(:shop)
|
||||
@domain.delete_at = Time.zone.parse('2010-07-05 10:00')
|
||||
end
|
||||
|
||||
teardown do
|
||||
travel_back
|
||||
end
|
||||
|
||||
def test_discarding_a_domain_persists_the_state
|
||||
@domain.discard
|
||||
@domain.reload
|
||||
assert @domain.discarded?
|
||||
end
|
||||
|
||||
def test_discarding_a_domain_schedules_deletion_at_random_time
|
||||
@domain.discard
|
||||
other_domain = domains(:airport)
|
||||
other_domain.delete_at = Time.zone.parse('2010-07-04')
|
||||
other_domain.discard
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
def test_discarding_a_domain_bypasses_validation
|
||||
domain = domains(:invalid)
|
||||
domain.delete_at = Time.zone.parse('2010-07-05 10:00')
|
||||
domain.discard
|
||||
domain.reload
|
||||
assert domain.discarded?
|
||||
end
|
||||
|
||||
def test_domain_cannot_be_discarded_repeatedly
|
||||
@domain.discard
|
||||
|
||||
exception = assert_raises do
|
||||
@domain.discard
|
||||
end
|
||||
assert_equal 'Domain is already discarded', exception.message
|
||||
end
|
||||
|
||||
def test_keeping_a_domain_bypasses_validation
|
||||
domain = domains(:invalid)
|
||||
domain.delete_at = Time.zone.parse('2010-07-05 10:00')
|
||||
domain.discard
|
||||
domain.keep
|
||||
domain.reload
|
||||
assert_not domain.discarded?
|
||||
end
|
||||
|
||||
def test_keeping_a_domain_cancels_domain_deletion
|
||||
@domain.discard
|
||||
@domain.keep
|
||||
assert_nil QueJob.find_by("args->>0 = '#{@domain.id}'", job_class: DomainDeleteJob.name)
|
||||
end
|
||||
end
|
|
@ -1,7 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DomainForceDeleteTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
||||
|
@ -74,7 +74,7 @@ class DomainForceDeleteTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_force_delete_cannot_be_scheduled_when_a_domain_is_discarded
|
||||
@domain.discard
|
||||
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
assert_raises StandardError do
|
||||
@domain.schedule_force_delete
|
||||
end
|
||||
|
|
|
@ -21,8 +21,8 @@ class ContactVersionsTest < ApplicationSystemTestCase
|
|||
VALUES (75, 'test_registrar', 'test123', 'test@test.com', 'EE', 'TEST123',
|
||||
'test123', 'en');
|
||||
|
||||
INSERT INTO contacts (id, code, auth_info, registrar_id)
|
||||
VALUES (75, 'test_code', '8b4d462aa04194ca78840a', 75);
|
||||
INSERT INTO contacts (id, code, email, auth_info, registrar_id)
|
||||
VALUES (75, 'test_code', 'test@inbox.test', '8b4d462aa04194ca78840a', 75);
|
||||
|
||||
INSERT INTO log_contacts (item_type, item_id, event, whodunnit, object,
|
||||
object_changes, created_at, session, children, ident_updated_at, uuid)
|
||||
|
|
|
@ -21,8 +21,8 @@ class DomainVersionsTest < ApplicationSystemTestCase
|
|||
VALUES (54, 'test_registrar', 'test123', 'test@test.com', 'EE', 'TEST123',
|
||||
'test123', 'en');
|
||||
|
||||
INSERT INTO contacts (id, code, auth_info, registrar_id)
|
||||
VALUES (54, 'test_code', '8b4d462aa04194ca78840a', 54);
|
||||
INSERT INTO contacts (id, code, email, auth_info, registrar_id)
|
||||
VALUES (54, 'test_code', 'test@inbox.test', '8b4d462aa04194ca78840a', 54);
|
||||
|
||||
INSERT INTO domains (id, registrar_id, valid_to, registrant_id,
|
||||
transfer_code)
|
||||
|
|
|
@ -7,9 +7,14 @@ class AdminAreaDomainDetailsTest < ApplicationSystemTestCase
|
|||
end
|
||||
|
||||
def test_discarded_domain_has_corresponding_label
|
||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||
@domain.delete_at = Time.zone.parse('2010-07-05 10:00')
|
||||
|
||||
visit admin_domain_url(@domain)
|
||||
assert_no_css 'span.label.label-warning', text: 'deleteCandidate'
|
||||
|
||||
@domain.discard
|
||||
|
||||
visit admin_domain_url(@domain)
|
||||
assert_css 'span.label.label-warning', text: 'deleteCandidate'
|
||||
end
|
||||
|
|
|
@ -56,7 +56,7 @@ class AdminAreaDomainForceDeleteTest < ApplicationSystemTestCase
|
|||
end
|
||||
|
||||
def test_force_delete_procedure_cannot_be_scheduled_on_a_discarded_domain
|
||||
@domain.discard
|
||||
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
|
||||
visit edit_admin_domain_url(@domain)
|
||||
assert_no_button 'Schedule force delete'
|
||||
|
|
|
@ -3,11 +3,29 @@ require 'test_helper'
|
|||
class AdminDomainsTestTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:admin)
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
||||
teardown do
|
||||
travel_back
|
||||
end
|
||||
|
||||
def test_shows_details
|
||||
domain = domains(:shop)
|
||||
visit admin_domain_path(domain)
|
||||
assert_field nil, with: domain.transfer_code
|
||||
visit admin_domain_path(@domain)
|
||||
assert_field nil, with: @domain.transfer_code
|
||||
end
|
||||
|
||||
def test_keep_a_domain
|
||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||
@domain.delete_at = Time.zone.parse('2010-07-05 10:00')
|
||||
@domain.discard
|
||||
|
||||
visit edit_admin_domain_url(@domain)
|
||||
click_link_or_button 'Remove deleteCandidate status'
|
||||
@domain.reload
|
||||
|
||||
assert_not @domain.discarded?
|
||||
assert_text 'deleteCandidate status has been removed'
|
||||
assert_no_link 'Remove deleteCandidate status'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue