mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 13:44:47 +02:00
Merge pull request #1039 from internetee/improve-whois-record-tests
Improve `WhoisRecord` tests
This commit is contained in:
commit
a00adbb6ca
1 changed files with 52 additions and 3 deletions
|
@ -18,9 +18,6 @@ class WhoisRecordTest < ActiveSupport::TestCase
|
||||||
expected_partial_hash = {
|
expected_partial_hash = {
|
||||||
disclaimer: expected_disclaimer_text,
|
disclaimer: expected_disclaimer_text,
|
||||||
name: 'shop.test',
|
name: 'shop.test',
|
||||||
registrant: 'John',
|
|
||||||
registrant_kind: 'priv',
|
|
||||||
email: 'john@inbox.test',
|
|
||||||
expire: '2010-07-05',
|
expire: '2010-07-05',
|
||||||
registrar_address: 'Main Street, New York, New York, 12345',
|
registrar_address: 'Main Street, New York, New York, 12345',
|
||||||
dnssec_keys: [],
|
dnssec_keys: [],
|
||||||
|
@ -60,4 +57,56 @@ class WhoisRecordTest < ActiveSupport::TestCase
|
||||||
refute_match(/Search results may not be used for commercial/, @record.body)
|
refute_match(/Search results may not be used for commercial/, @record.body)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_generates_json_with_registrant
|
||||||
|
registrant = contacts(:john).becomes(Registrant)
|
||||||
|
registrant.update!(name: 'John', kind: 'priv', email: 'john@shop.test',
|
||||||
|
updated_at: Time.zone.parse('2010-07-05'))
|
||||||
|
|
||||||
|
domain = domains(:shop)
|
||||||
|
domain.update!(registrant: registrant)
|
||||||
|
|
||||||
|
whois_record = whois_records(:shop)
|
||||||
|
whois_record.update!(json: {})
|
||||||
|
|
||||||
|
generated_json = whois_record.generate_json
|
||||||
|
assert_equal 'John', generated_json[:registrant]
|
||||||
|
assert_equal 'priv', generated_json[:registrant_kind]
|
||||||
|
assert_equal 'john@shop.test', generated_json[:email]
|
||||||
|
assert_equal '2010-07-05T00:00:00+03:00', generated_json[:registrant_changed]
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_generates_json_with_admin_contacts
|
||||||
|
contact = contacts(:john)
|
||||||
|
contact.update!(name: 'John', email: 'john@shop.test',
|
||||||
|
updated_at: Time.zone.parse('2010-07-05'))
|
||||||
|
|
||||||
|
domain = domains(:shop)
|
||||||
|
domain.admin_contacts = [contact]
|
||||||
|
|
||||||
|
whois_record = whois_records(:shop)
|
||||||
|
whois_record.update!(json: {})
|
||||||
|
|
||||||
|
admin_contact_json = whois_record.generate_json[:admin_contacts].first
|
||||||
|
assert_equal 'John', admin_contact_json[:name]
|
||||||
|
assert_equal 'john@shop.test', admin_contact_json[:email]
|
||||||
|
assert_equal '2010-07-05T00:00:00+03:00', admin_contact_json[:changed]
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_generates_json_with_tech_contacts
|
||||||
|
contact = contacts(:john)
|
||||||
|
contact.update!(name: 'John', email: 'john@shop.test',
|
||||||
|
updated_at: Time.zone.parse('2010-07-05'))
|
||||||
|
|
||||||
|
domain = domains(:shop)
|
||||||
|
domain.tech_contacts = [contact]
|
||||||
|
|
||||||
|
whois_record = whois_records(:shop)
|
||||||
|
whois_record.update!(json: {})
|
||||||
|
|
||||||
|
tech_contact_json = whois_record.generate_json[:tech_contacts].first
|
||||||
|
assert_equal 'John', tech_contact_json[:name]
|
||||||
|
assert_equal 'john@shop.test', tech_contact_json[:email]
|
||||||
|
assert_equal '2010-07-05T00:00:00+03:00', tech_contact_json[:changed]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue