Merge pull request #1039 from internetee/improve-whois-record-tests

Improve `WhoisRecord` tests
This commit is contained in:
Timo Võhmar 2018-12-03 10:52:53 +02:00 committed by GitHub
commit a00adbb6ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,9 +18,6 @@ class WhoisRecordTest < ActiveSupport::TestCase
expected_partial_hash = {
disclaimer: expected_disclaimer_text,
name: 'shop.test',
registrant: 'John',
registrant_kind: 'priv',
email: 'john@inbox.test',
expire: '2010-07-05',
registrar_address: 'Main Street, New York, New York, 12345',
dnssec_keys: [],
@ -60,4 +57,56 @@ class WhoisRecordTest < ActiveSupport::TestCase
refute_match(/Search results may not be used for commercial/, @record.body)
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