mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 05:34:46 +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,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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue