mirror of
https://github.com/internetee/registry.git
synced 2025-06-12 07:34:45 +02:00
Add disclaimer to whois JSON
This commit is contained in:
parent
764414ba34
commit
9c606bdf2f
3 changed files with 42 additions and 1 deletions
|
@ -51,4 +51,4 @@ class UpdateWhoisRecordJob < Que::Job
|
||||||
def delete_blocked(name)
|
def delete_blocked(name)
|
||||||
delete_reserved(name)
|
delete_reserved(name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,6 +36,7 @@ class WhoisRecord < ActiveRecord::Base
|
||||||
registrant = domain.registrant
|
registrant = domain.registrant
|
||||||
|
|
||||||
@disclosed = []
|
@disclosed = []
|
||||||
|
h[:disclaimer] = disclaimer_text
|
||||||
h[:name] = domain.name
|
h[:name] = domain.name
|
||||||
h[:status] = domain.statuses.map { |x| status_map[x] || x }
|
h[:status] = domain.statuses.map { |x| status_map[x] || x }
|
||||||
h[:registered] = domain.registered_at.try(:to_s, :iso8601)
|
h[:registered] = domain.registered_at.try(:to_s, :iso8601)
|
||||||
|
@ -120,4 +121,10 @@ class WhoisRecord < ActiveRecord::Base
|
||||||
def destroy_whois_record
|
def destroy_whois_record
|
||||||
Whois::Record.where(name: name).delete_all
|
Whois::Record.where(name: name).delete_all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def disclaimer_text
|
||||||
|
Setting.registry_whois_disclaimer
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
34
test/models/whois_record_test.rb
Normal file
34
test/models/whois_record_test.rb
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class WhoisRecordTest < ActiveSupport::TestCase
|
||||||
|
def setup
|
||||||
|
super
|
||||||
|
|
||||||
|
@domain = domains(:shop)
|
||||||
|
@record = WhoisRecord.new(domain: @domain)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_generated_json_has_expected_values
|
||||||
|
|
||||||
|
expected_disclaimer_text = <<-TEXT.squish
|
||||||
|
Search results may not be used for commercial, advertising, recompilation,
|
||||||
|
repackaging, redistribution, reuse, obscuring or other similar activities.
|
||||||
|
TEXT
|
||||||
|
|
||||||
|
expected_partial_hash = {
|
||||||
|
disclaimer: expected_disclaimer_text,
|
||||||
|
name: 'shop.test',
|
||||||
|
registrant: 'John',
|
||||||
|
registrant_kind: 'priv',
|
||||||
|
email: 'john@inbox.test',
|
||||||
|
expire: '2010-07-05',
|
||||||
|
nameservers: ['ns1.bestnames.test', 'ns2.bestnames.test'],
|
||||||
|
registrar_address: 'Main Street, New York, New York, 12345',
|
||||||
|
dnssec_keys: [],
|
||||||
|
}
|
||||||
|
|
||||||
|
expected_partial_hash.each do |key, value|
|
||||||
|
assert_equal(value, @record.generated_json[key])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue