diff --git a/app/interactions/domains/update_confirm/process_update_confirmed.rb b/app/interactions/domains/update_confirm/process_update_confirmed.rb
index 316c1db869..734dbf5d81 100644
--- a/app/interactions/domains/update_confirm/process_update_confirmed.rb
+++ b/app/interactions/domains/update_confirm/process_update_confirmed.rb
@@ -29,11 +29,17 @@ def update_domain
end
def assign_domain_update_meta
- user = ApiUser.find_by(id: domain.pending_json['current_user_id'])
+ user = ApiUser.find_by(id: user_id) if user_id.present? && user_id.is_a?(String)
domain.upid = user.registrar.id if user.present? && user.registrar
domain.up_date = Time.zone.now
end
+
+ private
+
+ def user_id
+ @user_id ||= domain.pending_json.dig('current_user_id')
+ end
end
end
end
diff --git a/test/jobs/domain_update_confirm_job_test.rb b/test/jobs/domain_update_confirm_job_test.rb
index aa686a9f84..183fd5cf1e 100644
--- a/test/jobs/domain_update_confirm_job_test.rb
+++ b/test/jobs/domain_update_confirm_job_test.rb
@@ -127,6 +127,29 @@ def test_protects_statuses_after_confirm
assert @domain.statuses.include? DomainStatus::DISPUTED
end
+ def test_works_id_current_user_id_broken
+ epp_xml = "\n\n \n \n \n #{@domain.name}\n" \
+ " \n #{@new_registrant.code}\n \n \n \n \n \n" \
+ " \n #{@legal_doc_path}\n \n" \
+ " \n 20alla-1594199756\n \n\n"
+ parsed_frame = Deserializers::Xml::DomainUpdate.new(Nokogiri::XML(epp_xml), @domain.registrar.id).call
+
+ @domain.pending_json['frame'] = parsed_frame
+ @domain.pending_json['current_user_id'] = { key: 'some_value'}
+ @domain.update(pending_json: @domain.pending_json)
+ @domain.update(statuses: [DomainStatus::DELETE_CANDIDATE, DomainStatus::DISPUTED])
+
+ assert_nothing_raised do
+ DomainUpdateConfirmJob.perform_now(@domain.id, RegistrantVerification::CONFIRMED)
+ end
+ @domain.reload
+
+ assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE_CONFIRMATION
+ assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE
+ assert @domain.statuses.include? DomainStatus::DELETE_CANDIDATE
+ assert @domain.statuses.include? DomainStatus::DISPUTED
+ end
+
def test_clears_pending_update_and_inactive_after_denial
epp_xml = "\n\n \n \n \n #{@domain.name}\n" \
" \n #{@new_registrant.code}\n \n \n \n \n \n" \