diff --git a/app/views/epp/poll/poll_req.xml.builder b/app/views/epp/poll/poll_req.xml.builder index d5da707a6..9981e8be6 100644 --- a/app/views/epp/poll/poll_req.xml.builder +++ b/app/views/epp/poll/poll_req.xml.builder @@ -5,7 +5,7 @@ xml.epp_head do end xml.tag!('msgQ', 'count' => current_user.queued_messages.count, 'id' => @message.id) do - xml.qDate @message.created_at.try(:iso8601) + xml.qDate @message.created_at.utc.xmlschema xml.msg @message.body end diff --git a/test/fixtures/messages.yml b/test/fixtures/messages.yml index 47cbdd0f2..a60ee762e 100644 --- a/test/fixtures/messages.yml +++ b/test/fixtures/messages.yml @@ -2,3 +2,9 @@ greeting: body: Welcome! queued: true registrar: bestnames + +domain_deleted: + body: Your domain has been deleted + queued: true + registrar: bestnames + created_at: <%= Time.zone.parse('2010-07-05') %> \ No newline at end of file diff --git a/test/integration/epp/poll_test.rb b/test/integration/epp/poll_test.rb index 30ee5c769..5a9f0deec 100644 --- a/test/integration/epp/poll_test.rb +++ b/test/integration/epp/poll_test.rb @@ -1,11 +1,27 @@ require 'test_helper' class EppPollTest < ApplicationIntegrationTest - def test_messages - post '/epp/command/poll', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' } - assert_equal '1301', Nokogiri::XML(response.body).at_css('result')[:code] - assert_equal 1, Nokogiri::XML(response.body).css('msgQ').size - assert_equal 1, Nokogiri::XML(response.body).css('result').size + # Deliberately does not conform to RFC5730, which requires the first message to be returned + def test_return_latest_message_when_queue_is_not_empty + message = messages(:domain_deleted) + + request_xml = <<-XML + + + + + + + XML + post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' + response_xml = Nokogiri::XML(response.body) + + assert_equal 1301.to_s, response_xml.at_css('result')[:code] + assert_equal 1, response_xml.css('result').size + assert_equal 2.to_s, response_xml.at_css('msgQ')[:count] + assert_equal message.id.to_s, response_xml.at_css('msgQ')[:id] + assert_equal Time.zone.parse('2010-07-05').utc.xmlschema, response_xml.at_css('msgQ qDate').text + assert_equal 'Your domain has been deleted', response_xml.at_css('msgQ msg').text end def test_no_messages