diff --git a/app/controllers/epp/polls_controller.rb b/app/controllers/epp/polls_controller.rb index 060931796..a93fa300d 100644 --- a/app/controllers/epp/polls_controller.rb +++ b/app/controllers/epp/polls_controller.rb @@ -12,9 +12,11 @@ module Epp @notification = current_user.unread_notifications.order('created_at DESC').take render_epp_response 'epp/poll/poll_no_messages' and return unless @notification + if @notification.attached_obj_type && @notification.attached_obj_id begin - @object = Object.const_get(@notification.attached_obj_type).find(@notification.attached_obj_id) + @object = object_by_type(@notification.attached_obj_type) + .find(@notification.attached_obj_id) rescue => problem # the data model might be inconsistent; or ... # this could happen if the registrar does not dequeue messages, and then the domain was deleted @@ -31,6 +33,12 @@ module Epp render_epp_response 'epp/poll/poll_req' end + def object_by_type(object_type) + Object.const_get(object_type) + rescue NameError + Object.const_get("Version::#{object_type}") + end + def ack_poll @notification = current_user.unread_notifications.find_by(id: params[:parsed_frame].css('poll').first['msgID']) diff --git a/test/integration/epp/poll_test.rb b/test/integration/epp/poll_test.rb index 6d3ec467e..a18fdbe4e 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_does_not_drop_error_if_old_version + version = Version::DomainVersion.last + @notification.update(attached_obj_type: 'DomainVersion', attached_obj_id: version.id) + + request_xml = <<-XML + + + + + + + XML + assert_nothing_raised do + post epp_poll_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + end + + xml_doc = Nokogiri::XML(response.body) + assert_epp_response :completed_successfully_ack_to_dequeue + assert_equal 2.to_s, xml_doc.at_css('msgQ')[:count] + assert_equal @notification.id.to_s, xml_doc.at_css('msgQ')[:id] + assert_equal Time.zone.parse('2010-07-05').utc.xmlschema, xml_doc.at_css('msgQ qDate').text + assert_equal 'Your domain has been updated', xml_doc.at_css('msgQ msg').text + end + def test_return_action_data_when_present @notification.update!(action: actions(:contact_update))