Improve domain discard

- Extract rake task domain:discard
- Remove background job when keeping a domain

#790
This commit is contained in:
Artur Beljajev 2018-04-08 00:36:00 +03:00
parent 00a30fc019
commit e776d09f9d
10 changed files with 104 additions and 46 deletions

View file

@ -5,10 +5,25 @@ class DomainDeletableTest < ActiveSupport::TestCase
@domain = domains(:shop)
end
def test_discard
refute @domain.discarded?
def test_discard_domain
@domain.discard
@domain.reload
assert QueJob.find_by("args->>0 = '#{@domain.id}'", job_class: DomainDeleteJob.name)
assert @domain.discarded?
end
def test_discard_invalid_domain
domain = domains(:invalid)
domain.discard
domain.reload
assert domain.discarded?, 'a domain should be discarded'
end
def test_keep_domain
@domain.discard
@domain.keep
@domain.reload
assert_nil QueJob.find_by("args->>0 = '#{@domain.id}'", job_class: DomainDeleteJob.name)
refute @domain.discarded?
end
end