mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 21:46:24 +02:00
Merge pull request #2504 from internetee/2503-invalid-disputed-statuses-on-domains-that-were-disputed-in-the-past
added cleaner for disputed domains with the closed disputed
This commit is contained in:
commit
dc4094ecda
2 changed files with 30 additions and 0 deletions
|
@ -8,6 +8,7 @@ class DisputeStatusUpdateJob < ApplicationJob
|
|||
|
||||
close_disputes
|
||||
activate_disputes
|
||||
clean_disputed
|
||||
|
||||
@logger.info "DisputeStatusUpdateJob - All done. Closed #{@backlog['closed']} and " \
|
||||
"activated #{@backlog['activated']} disputes."
|
||||
|
@ -15,6 +16,13 @@ class DisputeStatusUpdateJob < ApplicationJob
|
|||
show_failed_disputes unless @backlog['activate_fail'].empty? && @backlog['close_fail'].empty?
|
||||
end
|
||||
|
||||
def clean_disputed
|
||||
domains = Domain.where("array_to_string(statuses, '||') ILIKE ?", '%disputed%')
|
||||
domains.each do |domain|
|
||||
domain.unmark_as_disputed unless domain.disputed?
|
||||
end
|
||||
end
|
||||
|
||||
def close_disputes
|
||||
disputes = if @include_closed
|
||||
Dispute.where('expires_at < ?', Time.zone.today).all
|
||||
|
|
|
@ -73,4 +73,26 @@ class DisputeStatusUpdateJobTest < ActiveJob::TestCase
|
|||
whois_record.reload
|
||||
assert_not whois_record.json['status'].include? 'disputed'
|
||||
end
|
||||
|
||||
def test_close_dispute_with_domains_with_dispute_status
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
|
||||
domain = domains(:shop)
|
||||
domain.statuses << DomainStatus::DISPUTED
|
||||
domain.save && domain.reload
|
||||
|
||||
dispute = disputes(:closed)
|
||||
dispute.domain_name = domain.name
|
||||
dispute.save && dispute.reload
|
||||
|
||||
assert domain.statuses.include? DomainStatus::DISPUTED
|
||||
|
||||
perform_enqueued_jobs do
|
||||
DisputeStatusUpdateJob.perform_now
|
||||
end
|
||||
|
||||
domain.reload
|
||||
|
||||
refute domain.statuses.include? DomainStatus::DISPUTED
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue