mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 13:15:40 +02:00
Remove unused whois_records.body
DB column
Part of https://github.com/internetee/rest-whois/issues/131
This commit is contained in:
parent
dea84915b5
commit
1a1c3c7d85
8 changed files with 1 additions and 127 deletions
|
@ -25,18 +25,11 @@ class BlockedDomain < ActiveRecord::Base
|
|||
|
||||
wr = Whois::Record.find_or_initialize_by(name: name)
|
||||
wr.json = @json = generate_json # we need @json to bind to class
|
||||
wr.body = generate_body
|
||||
wr.save
|
||||
end
|
||||
|
||||
alias_method :update_whois_record, :generate_data
|
||||
|
||||
|
||||
def generate_body
|
||||
template = Rails.root.join("app/views/for_models/whois_other.erb".freeze)
|
||||
ERB.new(template.read, nil, "-").result(binding)
|
||||
end
|
||||
|
||||
def generate_json
|
||||
h = HashWithIndifferentAccess.new
|
||||
h[:name] = self.name
|
||||
|
|
|
@ -51,17 +51,10 @@ class ReservedDomain < ActiveRecord::Base
|
|||
|
||||
wr = Whois::Record.find_or_initialize_by(name: name)
|
||||
wr.json = @json = generate_json # we need @json to bind to class
|
||||
wr.body = generate_body
|
||||
wr.save
|
||||
end
|
||||
alias_method :update_whois_record, :generate_data
|
||||
|
||||
|
||||
def generate_body
|
||||
template = Rails.root.join("app/views/for_models/whois_other.erb".freeze)
|
||||
ERB.new(template.read, nil, "-").result(binding)
|
||||
end
|
||||
|
||||
def generate_json
|
||||
h = HashWithIndifferentAccess.new
|
||||
h[:name] = self.name
|
||||
|
|
|
@ -3,7 +3,7 @@ class WhoisRecord < ActiveRecord::Base
|
|||
belongs_to :domain
|
||||
belongs_to :registrar
|
||||
|
||||
validates :domain, :name, :body, :json, presence: true
|
||||
validates :domain, :name, :json, presence: true
|
||||
|
||||
before_validation :populate
|
||||
after_save :update_whois_server
|
||||
|
@ -87,23 +87,15 @@ class WhoisRecord < ActiveRecord::Base
|
|||
h
|
||||
end
|
||||
|
||||
def generated_body
|
||||
template_name = domain.discarded? ? 'whois_discarded.erb' : 'whois.erb'
|
||||
template = Rails.root.join("app/views/for_models/#{template_name}".freeze)
|
||||
ERB.new(template.read, nil, "-").result(binding)
|
||||
end
|
||||
|
||||
def populate
|
||||
return if domain_id.blank?
|
||||
self.json = generated_json
|
||||
self.body = generated_body
|
||||
self.name = json['name']
|
||||
self.registrar_id = domain.registrar_id if domain # for faster registrar updates
|
||||
end
|
||||
|
||||
def update_whois_server
|
||||
wd = Whois::Record.find_or_initialize_by(name: name)
|
||||
wd.body = body
|
||||
wd.json = json
|
||||
wd.save
|
||||
end
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
<%- if json['disclaimer'].present? -%>
|
||||
<%= json['disclaimer'].scan(/\S.{0,72}\S(?=\s|$)|\S+/).join("\n") %>
|
||||
<%- end -%>
|
||||
Estonia .ee Top Level Domain WHOIS server
|
||||
|
||||
Domain:
|
||||
name: <%= json['name'] %>
|
||||
<%- for st in Array(json['status']) -%>
|
||||
status: <%= st %>
|
||||
<%- end -%>
|
||||
registered: <%= json['registered'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
changed: <%= json['changed'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
expire: <%= json['expire'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
outzone: <%= json['outzone'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
delete: <%= json['delete'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
|
||||
Registrant:
|
||||
name: <%= json['registrant'] %>
|
||||
<% if json['registrant_kind'] != 'priv' -%>
|
||||
org id: <%= json['registrant_reg_no'] %>
|
||||
country: <%= json['registrant_ident_country_code'] %>
|
||||
<% end -%>
|
||||
email: Not Disclosed - Visit www.internet.ee for webbased WHOIS
|
||||
changed: <%= json['registrant_changed'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
|
||||
<%- if json['admin_contacts'].present? -%>
|
||||
Administrative contact:
|
||||
<%- for contact in json['admin_contacts'] -%>
|
||||
name: Not Disclosed
|
||||
email: Not Disclosed - Visit www.internet.ee for webbased WHOIS
|
||||
changed: Not Disclosed
|
||||
<%- end -%>
|
||||
|
||||
<%- end -%>
|
||||
<% if json['tech_contacts'].present? %>
|
||||
Technical contact:
|
||||
<%- for contact in json['tech_contacts'] -%>
|
||||
name: Not Disclosed
|
||||
email: Not Disclosed - Visit www.internet.ee for webbased WHOIS
|
||||
changed: Not Disclosed
|
||||
<%- end -%>
|
||||
|
||||
<%- end -%>
|
||||
Registrar:
|
||||
name: <%= json['registrar'] %>
|
||||
url: <%= json['registrar_website'] %>
|
||||
phone: <%= json['registrar_phone'] %>
|
||||
changed: <%= json['registrar_changed'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
|
||||
<%- if json['nameservers'].present? -%>
|
||||
Name servers:
|
||||
<%- for server in json['nameservers'] -%>
|
||||
nserver: <%= server %>
|
||||
<%- end -%>
|
||||
changed: <%= json['nameservers_changed'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
|
||||
<%- end -%>
|
||||
<%- if json['dnssec_keys'].present? -%>
|
||||
DNSSEC:
|
||||
<%- for key in json['dnssec_keys'] -%>
|
||||
dnskey: <%= key %>
|
||||
<%- end -%>
|
||||
changed: <%= json['dnssec_changed'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
|
||||
<%- end -%>
|
||||
Estonia .ee Top Level Domain WHOIS server
|
||||
More information at http://internet.ee
|
|
@ -1,8 +0,0 @@
|
|||
Estonia .ee Top Level Domain WHOIS server
|
||||
|
||||
Domain:
|
||||
name: <%= json['name'] %>
|
||||
status: <%= json['status'] %>
|
||||
|
||||
Estonia .ee Top Level Domain WHOIS server
|
||||
More information at http://internet.ee
|
|
@ -1,8 +0,0 @@
|
|||
Estonia .ee Top Level Domain WHOIS server
|
||||
|
||||
Domain:
|
||||
name: <%= @json['name'] %>
|
||||
status: <%= @json['status'] %>
|
||||
|
||||
Estonia .ee Top Level Domain WHOIS server
|
||||
More information at http://internet.ee
|
1
test/fixtures/whois_records.yml
vendored
1
test/fixtures/whois_records.yml
vendored
|
@ -1,6 +1,5 @@
|
|||
shop:
|
||||
name: shop.test
|
||||
domain: shop
|
||||
body: WHOIS text
|
||||
json:
|
||||
name: shop.test
|
||||
|
|
|
@ -32,29 +32,9 @@ class WhoisRecordTest < ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_generated_body_has_justified_disclaimer
|
||||
expected_disclaimer = begin
|
||||
'Search results may not be used for commercial, advertising, recompilation,\n' \
|
||||
'repackaging, redistribution, reuse, obscuring or other similar activities.'
|
||||
end
|
||||
expected_technical_contact = begin
|
||||
'Technical contact:\n' \
|
||||
'name: Not Disclosed\n' \
|
||||
'email: Not Disclosed - Visit www.internet.ee for webbased WHOIS\n' \
|
||||
'changed: Not Disclosed'
|
||||
end
|
||||
|
||||
regexp_contact = Regexp.new(expected_technical_contact, Regexp::MULTILINE)
|
||||
regexp_disclaimer = Regexp.new(expected_disclaimer, Regexp::MULTILINE)
|
||||
|
||||
assert_match(regexp_disclaimer, @record.body)
|
||||
assert_match(regexp_contact, @record.body)
|
||||
end
|
||||
|
||||
def test_whois_record_has_no_disclaimer_if_Setting_is_blank
|
||||
Setting.stubs(:registry_whois_disclaimer, '') do
|
||||
refute(@record.json['disclaimer'])
|
||||
refute_match(/Search results may not be used for commercial/, @record.body)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue