Rename Message to Notification

This commit is contained in:
Artur Beljajev 2018-08-23 20:03:03 +03:00
parent 5ba2170324
commit 8765baf319
32 changed files with 243 additions and 229 deletions

View file

@ -47,7 +47,7 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
def test_notifies_old_registrar
@old_registrar = @domain.registrar
assert_difference -> { @old_registrar.messages.count } do
assert_difference -> { @old_registrar.notifications.count } do
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
end
end

View file

@ -43,7 +43,7 @@ class EppDomainTransferRequestTest < ApplicationIntegrationTest
def test_notifies_old_registrar
@old_registrar = @domain.registrar
assert_difference -> { @old_registrar.messages.count } do
assert_difference -> { @old_registrar.notifications.count } do
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
end
end

View file

@ -2,8 +2,8 @@ require 'test_helper'
class EppPollTest < ApplicationIntegrationTest
# 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)
def test_return_latest_notification_when_queue_is_not_empty
notification = notifications(:domain_deleted)
request_xml =
<<-XML
@ -20,13 +20,13 @@ class EppPollTest < ApplicationIntegrationTest
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 notification.id.to_s, response_xml.at_css('msgQ')[:id]
assert_equal Time.zone.parse('2010-07-05').iso8601, 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_in_queue
registrars(:bestnames).messages.delete_all(:delete_all)
def test_no_notifications
registrars(:bestnames).notifications.delete_all(:delete_all)
request_xml =
<<-XML
@ -44,49 +44,49 @@ class EppPollTest < ApplicationIntegrationTest
assert_equal 1, response_xml.css('result').size
end
def test_dequeue_message
message = messages(:greeting)
def test_dequeue_notification
notification = notifications(:greeting)
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="ack" msgID="#{message.id}"/>
<poll op="ack" msgID="#{notification.id}"/>
</command>
</epp>
XML
post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
message.reload
notification.reload
response_xml = Nokogiri::XML(response.body)
assert_not message.queued?
assert_not notification.queued?
assert_equal 1000.to_s, response_xml.at_css('result')[:code]
assert_equal 1, response_xml.css('result').size
assert_equal 1.to_s, response_xml.at_css('msgQ')[:count]
assert_equal message.id.to_s, response_xml.at_css('msgQ')[:id]
assert_equal notification.id.to_s, response_xml.at_css('msgQ')[:id]
end
def test_message_of_other_registrars_cannot_be_dequeued
message = messages(:farewell)
def test_notification_of_other_registrars_cannot_be_dequeued
notification = notifications(:farewell)
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="ack" msgID="#{message.id}"/>
<poll op="ack" msgID="#{notification.id}"/>
</command>
</epp>
XML
post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
response_xml = Nokogiri::XML(response.body)
message.reload
notification.reload
assert message.queued?
assert notification.queued?
assert_equal 2303.to_s, response_xml.at_css('result')[:code]
end
def test_message_not_found
def test_notification_not_found
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">

View file

@ -18,19 +18,19 @@ class DomainDeleteConfirmJobTest < ActiveSupport::TestCase
super
end
def test_rejected_registrant_verification_polls_a_message
def test_rejected_registrant_verification_notifies_registrar
DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::REJECTED)
last_registrar_message = @domain.registrar.messages.last
assert_equal(last_registrar_message.attached_obj_id, @domain.id)
assert_equal(last_registrar_message.body, 'Registrant rejected domain deletion: shop.test')
last_registrar_notification = @domain.registrar.notifications.last
assert_equal(last_registrar_notification.attached_obj_id, @domain.id)
assert_equal(last_registrar_notification.body, 'Registrant rejected domain deletion: shop.test')
end
def test_accepted_registrant_verification_polls_a_message
def test_accepted_registrant_verification_notifies_registrar
DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::CONFIRMED)
last_registrar_message = @domain.registrar.messages.last
assert_equal(last_registrar_message.attached_obj_id, @domain.id)
assert_equal(last_registrar_message.body, 'Registrant confirmed domain deletion: shop.test')
last_registrar_notification = @domain.registrar.notifications.last
assert_equal(last_registrar_notification.attached_obj_id, @domain.id)
assert_equal(last_registrar_notification.body, 'Registrant confirmed domain deletion: shop.test')
end
end

View file

@ -18,19 +18,19 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
super
end
def test_rejected_registrant_verification_polls_a_message
def test_rejected_registrant_verification_notifies_registrar
DomainUpdateConfirmJob.enqueue(@domain.id, RegistrantVerification::REJECTED)
last_registrar_message = @domain.registrar.messages.last
assert_equal(last_registrar_message.attached_obj_id, @domain.id)
assert_equal(last_registrar_message.body, 'Registrant rejected domain update: shop.test')
last_registrar_notification = @domain.registrar.notifications.last
assert_equal(last_registrar_notification.attached_obj_id, @domain.id)
assert_equal(last_registrar_notification.body, 'Registrant rejected domain update: shop.test')
end
def test_accepted_registrant_verification_polls_a_message
def test_accepted_registrant_verification_notifies_registrar
DomainUpdateConfirmJob.enqueue(@domain.id, RegistrantVerification::CONFIRMED)
last_registrar_message = @domain.registrar.messages.last
assert_equal(last_registrar_message.attached_obj_id, @domain.id)
assert_equal(last_registrar_message.body, 'Registrant confirmed domain update: shop.test')
last_registrar_notification = @domain.registrar.notifications.last
assert_equal(last_registrar_notification.attached_obj_id, @domain.id)
assert_equal(last_registrar_notification.body, 'Registrant confirmed domain update: shop.test')
end
end

View file

@ -14,7 +14,7 @@ class DomainTransferTest < ActiveSupport::TestCase
def test_notifies_old_registrar_on_approval
old_registrar = @domain_transfer.old_registrar
assert_difference -> { old_registrar.messages.count } do
assert_difference -> { old_registrar.notifications.count } do
@domain_transfer.approve
end
@ -24,9 +24,9 @@ class DomainTransferTest < ActiveSupport::TestCase
id = @domain_transfer.id
class_name = @domain_transfer.class.name
message = old_registrar.messages.last
assert_equal body, message.body
assert_equal id, message.attached_obj_id
assert_equal class_name, message.attached_obj_type
notification = old_registrar.notifications.last
assert_equal body, notification.body
assert_equal id, notification.attached_obj_id
assert_equal class_name, notification.attached_obj_type
end
end

View file

@ -1,27 +0,0 @@
require 'test_helper'
class MessageTest < ActiveSupport::TestCase
setup do
@message = messages(:greeting)
end
def test_valid
assert @message.valid?
end
def test_invalid_without_body
@message.body = nil
assert @message.invalid?
end
def test_invalid_without_registrar
@message.registrar = nil
assert @message.invalid?
end
def test_dequeue
@message.dequeue
@message.reload
assert_not @message.queued?
end
end

View file

@ -0,0 +1,27 @@
require 'test_helper'
class NotificationTest < ActiveSupport::TestCase
setup do
@notification = notifications(:greeting)
end
def test_valid
assert @notification.valid?
end
def test_invalid_without_body
@notification.body = nil
assert @notification.invalid?
end
def test_invalid_without_registrar
@notification.registrar = nil
assert @notification.invalid?
end
def test_dequeue
@notification.dequeue
@notification.reload
assert_not @notification.queued?
end
end

View file

@ -22,7 +22,7 @@ class AdminAreaDomainForceDeleteTest < ApplicationSystemTestCase
end
def test_notifies_registrar
assert_difference '@domain.registrar.messages.size' do
assert_difference '@domain.registrar.notifications.size' do
visit edit_admin_domain_url(@domain)
click_link_or_button 'Force delete domain'
end