mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 19:20:37 +02:00
Introduce Contact#deletable?
This commit is contained in:
parent
d14fa5b701
commit
7c768616a2
4 changed files with 31 additions and 20 deletions
|
@ -552,4 +552,8 @@ class Contact < ActiveRecord::Base
|
|||
def registrant?
|
||||
registrant_domains.any?
|
||||
end
|
||||
|
||||
def deletable?
|
||||
!linked?
|
||||
end
|
||||
end
|
||||
|
|
8
test/fixtures/contacts.yml
vendored
8
test/fixtures/contacts.yml
vendored
|
@ -78,14 +78,6 @@ identical_to_william:
|
|||
auth_info: 5ab865
|
||||
uuid: c0a191d5-3793-4f0b-8f85-491612d0293e
|
||||
|
||||
not_in_use:
|
||||
name: Useless
|
||||
email: useless@inbox.test
|
||||
registrar: bestnames
|
||||
code: not-in-use
|
||||
auth_info: e75a2a
|
||||
uuid: ca613cc5-a8dc-48c1-8d32-d3c6a0b6c952
|
||||
|
||||
invalid:
|
||||
name: any
|
||||
code: invalid
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppContactDeleteBaseTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@contact = contacts(:john)
|
||||
end
|
||||
|
||||
def test_deletes_a_contact_that_is_not_in_use
|
||||
@contact = contacts(:not_in_use)
|
||||
def test_deletes_contact
|
||||
contact = deletable_contact
|
||||
|
||||
# https://github.com/internetee/registry/issues/415
|
||||
@contact.update_columns(code: @contact.code.upcase)
|
||||
contact.update_columns(code: contact.code.upcase)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
@ -17,7 +13,7 @@ class EppContactDeleteBaseTest < ActionDispatch::IntegrationTest
|
|||
<command>
|
||||
<delete>
|
||||
<contact:delete xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:id>not-in-use</contact:id>
|
||||
<contact:id>#{contact.code}</contact:id>
|
||||
</contact:delete>
|
||||
</delete>
|
||||
</command>
|
||||
|
@ -32,11 +28,12 @@ class EppContactDeleteBaseTest < ActionDispatch::IntegrationTest
|
|||
assert_equal 1, response_xml.css('result').size
|
||||
end
|
||||
|
||||
def test_contact_that_is_in_use_cannot_be_deleted
|
||||
assert_equal 'john-001', @contact.code
|
||||
def test_undeletable_cannot_be_deleted
|
||||
contact = contacts(:john)
|
||||
assert_not contact.deletable?
|
||||
|
||||
# https://github.com/internetee/registry/issues/415
|
||||
@contact.update_columns(code: @contact.code.upcase)
|
||||
contact.update_columns(code: contact.code.upcase)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
@ -44,7 +41,7 @@ class EppContactDeleteBaseTest < ActionDispatch::IntegrationTest
|
|||
<command>
|
||||
<delete>
|
||||
<contact:delete xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:id>john-001</contact:id>
|
||||
<contact:id>#{contact.code}</contact:id>
|
||||
</contact:delete>
|
||||
</delete>
|
||||
</command>
|
||||
|
@ -57,4 +54,12 @@ class EppContactDeleteBaseTest < ActionDispatch::IntegrationTest
|
|||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '2305', response_xml.at_css('result')[:code]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def deletable_contact
|
||||
Domain.update_all(registrant_id: contacts(:william))
|
||||
DomainContact.delete_all
|
||||
contacts(:john)
|
||||
end
|
||||
end
|
|
@ -44,6 +44,16 @@ class ContactTest < ActiveSupport::TestCase
|
|||
assert_not contact.managed_by?(user)
|
||||
end
|
||||
|
||||
def test_deletable_when_not_linked
|
||||
contact = unlinked_contact
|
||||
assert contact.deletable?
|
||||
end
|
||||
|
||||
def test_undeletable_when_linked
|
||||
assert @contact.linked?
|
||||
assert_not @contact.deletable?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def unlinked_contact
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue