mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 04:37:30 +02:00
Hide method
This commit is contained in:
parent
42e8f86dae
commit
4894b39f0f
8 changed files with 57 additions and 85 deletions
|
@ -1,16 +1,6 @@
|
||||||
module Concerns::Domain::Discardable
|
module Concerns::Domain::Discardable
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
def discard
|
|
||||||
raise 'Domain is already discarded' if discarded?
|
|
||||||
|
|
||||||
statuses << DomainStatus::DELETE_CANDIDATE
|
|
||||||
transaction do
|
|
||||||
save(validate: false)
|
|
||||||
delete_later
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def keep
|
def keep
|
||||||
statuses.delete(DomainStatus::DELETE_CANDIDATE)
|
statuses.delete(DomainStatus::DELETE_CANDIDATE)
|
||||||
transaction do
|
transaction do
|
||||||
|
@ -22,4 +12,14 @@ module Concerns::Domain::Discardable
|
||||||
def discarded?
|
def discarded?
|
||||||
statuses.include?(DomainStatus::DELETE_CANDIDATE)
|
statuses.include?(DomainStatus::DELETE_CANDIDATE)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def discard
|
||||||
|
statuses << DomainStatus::DELETE_CANDIDATE
|
||||||
|
transaction do
|
||||||
|
save(validate: false)
|
||||||
|
delete_later
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,9 +31,7 @@ class EppDomainDeleteTest < ApplicationIntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_discarded_domain_cannot_be_deleted
|
def test_discarded_domain_cannot_be_deleted
|
||||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||||
@domain.delete_at = Time.zone.parse('2010-07-05 10:00')
|
|
||||||
@domain.discard
|
|
||||||
|
|
||||||
request_xml = <<-XML
|
request_xml = <<-XML
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
|
|
@ -32,9 +32,7 @@ class EppDomainUpdateTest < ApplicationIntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_discarded_domain_cannot_be_updated
|
def test_discarded_domain_cannot_be_updated
|
||||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||||
@domain.delete_at = Time.zone.parse('2010-07-05 10:00')
|
|
||||||
@domain.discard
|
|
||||||
|
|
||||||
request_xml = <<-XML
|
request_xml = <<-XML
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
|
|
@ -81,9 +81,7 @@ class EppDomainTransferRequestTest < ApplicationIntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_discarded_domain_cannot_be_transferred
|
def test_discarded_domain_cannot_be_transferred
|
||||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||||
@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' }
|
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||||
@domain.reload
|
@domain.reload
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
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
|
|
|
@ -50,4 +50,46 @@ class DomainReleasableDiscardableTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
assert_not @domain.discarded?
|
assert_not @domain.discarded?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_discarding_a_domain_schedules_deletion_at_random_time
|
||||||
|
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||||
|
@domain.update_columns(delete_at: Time.zone.parse('2010-07-05 10:00'))
|
||||||
|
Domain.release_domains
|
||||||
|
|
||||||
|
other_domain = domains(:airport)
|
||||||
|
other_domain.update_columns(delete_at: Time.zone.parse('2010-07-05 10:00'))
|
||||||
|
Domain.release_domains
|
||||||
|
|
||||||
|
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
|
||||||
|
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||||
|
domain = domains(:invalid)
|
||||||
|
domain.update_columns(delete_at: Time.zone.parse('2010-07-05 10:00'))
|
||||||
|
|
||||||
|
Domain.release_domains
|
||||||
|
domain.reload
|
||||||
|
|
||||||
|
assert domain.discarded?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_keeping_a_domain_bypasses_validation
|
||||||
|
domain = domains(:invalid)
|
||||||
|
domain.update_columns(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||||
|
|
||||||
|
domain.keep
|
||||||
|
domain.reload
|
||||||
|
|
||||||
|
assert_not domain.discarded?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_keeping_a_domain_cancels_domain_deletion
|
||||||
|
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||||
|
@domain.keep
|
||||||
|
assert_nil QueJob.find_by("args->>0 = '#{@domain.id}'", job_class: DomainDeleteJob.name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@ class AdminAreaDomainDetailsTest < ApplicationSystemTestCase
|
||||||
visit admin_domain_url(@domain)
|
visit admin_domain_url(@domain)
|
||||||
assert_no_css 'span.label.label-warning', text: 'deleteCandidate'
|
assert_no_css 'span.label.label-warning', text: 'deleteCandidate'
|
||||||
|
|
||||||
@domain.discard
|
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||||
|
|
||||||
visit admin_domain_url(@domain)
|
visit admin_domain_url(@domain)
|
||||||
assert_css 'span.label.label-warning', text: 'deleteCandidate'
|
assert_css 'span.label.label-warning', text: 'deleteCandidate'
|
||||||
|
|
|
@ -29,8 +29,7 @@ class AdminDomainsTestTest < ApplicationSystemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_keep_a_domain
|
def test_keep_a_domain
|
||||||
@domain.delete_at = Time.zone.parse('2010-07-05 10:00')
|
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||||
@domain.discard
|
|
||||||
|
|
||||||
visit edit_admin_domain_url(@domain)
|
visit edit_admin_domain_url(@domain)
|
||||||
click_link_or_button 'Remove deleteCandidate status'
|
click_link_or_button 'Remove deleteCandidate status'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue