mirror of
https://github.com/internetee/registry.git
synced 2025-07-31 06:56:23 +02:00
Prevent deprecated validations when email is changed
This commit is contained in:
parent
7a2256ae93
commit
ec71ae1137
2 changed files with 32 additions and 2 deletions
|
@ -115,8 +115,9 @@ module Actions
|
||||||
contact.email_history = old_email
|
contact.email_history = old_email
|
||||||
updated = contact.save
|
updated = contact.save
|
||||||
|
|
||||||
if updated && email_changed && contact.registrant?
|
if updated && email_changed
|
||||||
ContactMailer.email_changed(contact: contact, old_email: old_email).deliver_now
|
contact.validation_events.where('event_data @> ?', { 'email': old_email }.to_json).destroy_all
|
||||||
|
ContactMailer.email_changed(contact: contact, old_email: old_email).deliver_now if contact.registrant?
|
||||||
end
|
end
|
||||||
|
|
||||||
updated
|
updated
|
||||||
|
|
|
@ -80,6 +80,35 @@ class EppContactUpdateBaseTest < EppTestCase
|
||||||
assert_emails 1
|
assert_emails 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_destroy_old_validation_when_email_is_changed
|
||||||
|
@contact.verify_email
|
||||||
|
old_validation_event = @contact.validation_events.first
|
||||||
|
@contact.update_columns(code: @contact.code.upcase)
|
||||||
|
|
||||||
|
request_xml = <<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee', for_version: '1.0')}">
|
||||||
|
<command>
|
||||||
|
<update>
|
||||||
|
<contact:update xmlns:contact="#{Xsd::Schema.filename(for_prefix: 'contact-ee', for_version: '1.1')}">
|
||||||
|
<contact:id>john-001</contact:id>
|
||||||
|
<contact:chg>
|
||||||
|
<contact:email>john-new@inbox.test</contact:email>
|
||||||
|
</contact:chg>
|
||||||
|
</contact:update>
|
||||||
|
</update>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
XML
|
||||||
|
|
||||||
|
post epp_update_path, params: { frame: request_xml },
|
||||||
|
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||||
|
|
||||||
|
assert_raises(ActiveRecord::RecordNotFound) do
|
||||||
|
ValidationEvent.find(old_validation_event.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_skips_notifying_contact_when_email_is_not_changed
|
def test_skips_notifying_contact_when_email_is_not_changed
|
||||||
assert_equal 'john-001', @contact.code
|
assert_equal 'john-001', @contact.code
|
||||||
assert_equal 'john@inbox.test', @contact.email
|
assert_equal 'john@inbox.test', @contact.email
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue