mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 04:37:30 +02:00
Fix old classnames saved in notification, add tests
This commit is contained in:
parent
0cb45f6e60
commit
c405fcdd34
2 changed files with 34 additions and 1 deletions
|
@ -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'])
|
||||
|
||||
|
|
|
@ -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 version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<poll op="req"/>
|
||||
</command>
|
||||
</epp>
|
||||
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))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue