mirror of
https://github.com/internetee/registry.git
synced 2025-06-09 22:24:47 +02:00
commit
68faff40cc
10 changed files with 87 additions and 93 deletions
|
@ -1,6 +1,6 @@
|
|||
class Registrant::DomainUpdateConfirmsController < RegistrantController
|
||||
skip_before_action :authenticate_user!, only: [:show, :update]
|
||||
skip_authorization_check only: [:show, :update]
|
||||
skip_before_action :authenticate_user!, only: %i[show update]
|
||||
skip_authorization_check only: %i[show update]
|
||||
|
||||
def show
|
||||
return if params[:confirmed] || params[:rejected]
|
||||
|
|
|
@ -23,7 +23,9 @@ class DomainUpdateConfirmJob < Que::Job
|
|||
registrant: domain.registrant).deliver_now
|
||||
|
||||
domain.poll_message!(:poll_pending_update_rejected_by_registrant)
|
||||
domain.clean_pendings_lowlevel
|
||||
|
||||
domain.preclean_pendings
|
||||
domain.clean_pendings!
|
||||
end
|
||||
destroy # it's best to destroy the job in the same transaction
|
||||
end
|
||||
|
|
|
@ -294,36 +294,6 @@ class Domain < ActiveRecord::Base
|
|||
save
|
||||
end
|
||||
|
||||
|
||||
# state changes may be done low-level - no validation
|
||||
# in this metod we still save PaperTrail log.
|
||||
def clean_pendings_lowlevel
|
||||
statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION)
|
||||
statuses.delete(DomainStatus::PENDING_UPDATE)
|
||||
statuses.delete(DomainStatus::PENDING_DELETE)
|
||||
|
||||
status_notes[DomainStatus::PENDING_UPDATE] = ''
|
||||
status_notes[DomainStatus::PENDING_DELETE] = ''
|
||||
|
||||
hash = {
|
||||
registrant_verification_token: nil,
|
||||
registrant_verification_asked_at: nil,
|
||||
pending_json: {},
|
||||
status_notes: status_notes,
|
||||
statuses: statuses.presence || [DomainStatus::OK],
|
||||
# need this column in order to update PaperTrail version properly
|
||||
updated_at: Time.now.utc
|
||||
}
|
||||
|
||||
# PaperTrail
|
||||
self.attributes = hash
|
||||
record_update
|
||||
clear_version_instance!
|
||||
reset_transaction_id
|
||||
|
||||
update_columns(hash)
|
||||
end
|
||||
|
||||
def pending_update!
|
||||
return true if pending_update?
|
||||
self.epp_pending_update = true # for epp
|
||||
|
|
|
@ -21,7 +21,10 @@ class DomainCron
|
|||
if domain.pending_delete? || domain.pending_delete_confirmation?
|
||||
DomainMailer.pending_delete_expired_notification(domain.id, true).deliver
|
||||
end
|
||||
domain.clean_pendings_lowlevel
|
||||
|
||||
domain.preclean_pendings
|
||||
domain.clean_pendings!
|
||||
|
||||
unless Rails.env.test?
|
||||
STDOUT << "#{Time.zone.now.utc} DomainCron.clean_expired_pendings: ##{domain.id} (#{domain.name})\n"
|
||||
end
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe DomainDeleteConfirmEmailJob do
|
||||
describe '#run' do
|
||||
let(:domain) { instance_double(Domain) }
|
||||
let(:message) { instance_double(ActionMailer::MessageDelivery) }
|
||||
|
||||
before :example do
|
||||
expect(Domain).to receive(:find).and_return(domain)
|
||||
allow(domain).to receive_messages(
|
||||
id: 1,
|
||||
name: 'test.com',
|
||||
registrant_email: 'registrant@test.com',
|
||||
registrar: 'registrar',
|
||||
registrant: 'registrant')
|
||||
end
|
||||
|
||||
after :example do
|
||||
domain_id = 1
|
||||
described_class.enqueue(domain_id)
|
||||
end
|
||||
|
||||
it 'creates log record' do
|
||||
log_message = 'Send DomainDeleteMailer#confirm email for domain test.com (#1) to registrant@test.com'
|
||||
|
||||
allow(DomainDeleteMailer).to receive(:confirm).and_return(message)
|
||||
allow(message).to receive(:deliver_now)
|
||||
|
||||
expect(Rails.logger).to receive(:info).with(log_message)
|
||||
end
|
||||
|
||||
it 'sends email' do
|
||||
expect(DomainDeleteMailer).to receive(:confirm).with(domain: domain,
|
||||
registrar: 'registrar',
|
||||
registrant: 'registrant')
|
||||
.and_return(message)
|
||||
expect(message).to receive(:deliver_now)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,18 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe DomainUpdateConfirmJob do
|
||||
let(:domain) { instance_spy(Epp::Domain, registrant: registrant, errors: []) }
|
||||
let(:registrant) { instance_double(Registrant) }
|
||||
let(:registrant_change) { instance_spy(RegistrantChange) }
|
||||
|
||||
it 'confirms registrant change' do
|
||||
expect(Epp::Domain).to receive(:find).and_return(domain)
|
||||
expect(RegistrantChange).to receive(:new)
|
||||
.with(domain: domain, old_registrant: registrant)
|
||||
.and_return(registrant_change)
|
||||
|
||||
described_class.enqueue(domain_id = nil, action = RegistrantVerification::CONFIRMED)
|
||||
|
||||
expect(registrant_change).to have_received(:confirm)
|
||||
end
|
||||
end
|
1
test/fixtures/invoices.yml
vendored
1
test/fixtures/invoices.yml
vendored
|
@ -35,5 +35,4 @@ overdue:
|
|||
for_payments_test:
|
||||
<<: *DEFAULTS
|
||||
total: 12.00
|
||||
id: 1
|
||||
number: 1
|
||||
|
|
6
test/fixtures/whois_records.yml
vendored
Normal file
6
test/fixtures/whois_records.yml
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
shop:
|
||||
name: shop.test
|
||||
domain: shop
|
||||
body: WHOIS text
|
||||
json:
|
||||
name: shop.test
|
36
test/jobs/domain_delete_confirm_job_test.rb
Normal file
36
test/jobs/domain_delete_confirm_job_test.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
require "test_helper"
|
||||
|
||||
class DomainDeleteConfirmJobTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
super
|
||||
|
||||
@domain = domains(:shop)
|
||||
@new_registrant = contacts(:william)
|
||||
@user = users(:api_bestnames)
|
||||
|
||||
@domain.update!(pending_json: { new_registrant_id: @new_registrant.id,
|
||||
new_registrant_name: @new_registrant.name,
|
||||
new_registrant_email: @new_registrant.email,
|
||||
current_user_id: @user.id })
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
end
|
||||
|
||||
def test_rejected_registrant_verification_polls_a_message
|
||||
DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::REJECTED)
|
||||
|
||||
last_registrar_message = @domain.registrar.messages.last
|
||||
assert_equal(last_registrar_message.attached_obj_id, @domain.id)
|
||||
assert_equal(last_registrar_message.body, 'Registrant rejected domain deletion: shop.test')
|
||||
end
|
||||
|
||||
def test_accepted_registrant_verification_polls_a_message
|
||||
DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::CONFIRMED)
|
||||
|
||||
last_registrar_message = @domain.registrar.messages.last
|
||||
assert_equal(last_registrar_message.attached_obj_id, @domain.id)
|
||||
assert_equal(last_registrar_message.body, 'Registrant confirmed domain deletion: shop.test')
|
||||
end
|
||||
end
|
36
test/jobs/domain_update_confirm_job_test.rb
Normal file
36
test/jobs/domain_update_confirm_job_test.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
require "test_helper"
|
||||
|
||||
class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
super
|
||||
|
||||
@domain = domains(:shop)
|
||||
@new_registrant = contacts(:william)
|
||||
@user = users(:api_bestnames)
|
||||
|
||||
@domain.update!(pending_json: { new_registrant_id: @new_registrant.id,
|
||||
new_registrant_name: @new_registrant.name,
|
||||
new_registrant_email: @new_registrant.email,
|
||||
current_user_id: @user.id })
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
end
|
||||
|
||||
def test_rejected_registrant_verification_polls_a_message
|
||||
DomainUpdateConfirmJob.enqueue(@domain.id, RegistrantVerification::REJECTED)
|
||||
|
||||
last_registrar_message = @domain.registrar.messages.last
|
||||
assert_equal(last_registrar_message.attached_obj_id, @domain.id)
|
||||
assert_equal(last_registrar_message.body, 'Registrant rejected domain update: shop.test')
|
||||
end
|
||||
|
||||
def test_accepted_registrant_verification_polls_a_message
|
||||
DomainUpdateConfirmJob.enqueue(@domain.id, RegistrantVerification::CONFIRMED)
|
||||
|
||||
last_registrar_message = @domain.registrar.messages.last
|
||||
assert_equal(last_registrar_message.attached_obj_id, @domain.id)
|
||||
assert_equal(last_registrar_message.body, 'Registrant confirmed domain update: shop.test')
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue