From 9c6527d6d3ffbfd7a16fd141909afb5809568495 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Wed, 7 Jul 2021 15:38:08 +0500 Subject: [PATCH] Mask orphan notification as read --- app/controllers/epp/polls_controller.rb | 1 + test/integration/epp/poll_test.rb | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/app/controllers/epp/polls_controller.rb b/app/controllers/epp/polls_controller.rb index 86218336b..01cb719c4 100644 --- a/app/controllers/epp/polls_controller.rb +++ b/app/controllers/epp/polls_controller.rb @@ -27,6 +27,7 @@ module Epp Rails.logger.error 'orphan message, error ignored: ' + problem.to_s # now we should dequeue or delete the messages avoid duplicate log alarms + @notification.mark_as_read end end diff --git a/test/integration/epp/poll_test.rb b/test/integration/epp/poll_test.rb index 5cdb7e524..e3fbb0daf 100644 --- a/test/integration/epp/poll_test.rb +++ b/test/integration/epp/poll_test.rb @@ -26,6 +26,31 @@ class EppPollTest < EppTestCase assert_equal 'Your domain has been updated', xml_doc.at_css('msgQ msg').text end + def test_clears_orphan_messages_if_any + # To check if we are clearing orphan messages we need to create a message not linked to any + # existing Epp::Domain + + orphan_notification = @notification.dup + orphan_notification.attached_obj_type = Epp::Domain + orphan_notification.attached_obj_id = rand(Epp::Domain.first.id-1) + orphan_notification.save! + assert orphan_notification.unread? + + request_xml = <<-XML + + + + + + + XML + post epp_poll_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + + orphan_notification.reload + refute orphan_notification.unread? + end + def test_does_not_drop_error_if_old_version version = Version::DomainVersion.last @notification.update(attached_obj_type: 'DomainVersion', attached_obj_id: version.id)