diff --git a/app/models/domain.rb b/app/models/domain.rb
index b706744bd..e57117bc2 100644
--- a/app/models/domain.rb
+++ b/app/models/domain.rb
@@ -18,6 +18,7 @@ class Domain < ApplicationRecord
alias_attribute :on_hold_time, :outzone_at
alias_attribute :outzone_time, :outzone_at
alias_attribute :auth_info, :transfer_code # Old attribute name; for PaperTrail
+ alias_attribute :registered_at, :created_at
# TODO: whois requests ip whitelist for full info for own domains and partial info for other domains
# TODO: most inputs should be trimmed before validatation, probably some global logic?
@@ -627,7 +628,7 @@ class Domain < ApplicationRecord
def as_json(_options)
hash = super
hash['auth_info'] = hash.delete('transfer_code') # API v1 requirement
- hash['valid_from'] = hash['registered_at'] # API v1 requirement
+ hash['valid_from'] = hash['created_at'] # API v1 requirement
hash.delete('statuses_before_force_delete')
hash
end
diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb
index a6fe58c71..7cfe3107a 100644
--- a/app/models/epp/domain.rb
+++ b/app/models/epp/domain.rb
@@ -41,7 +41,6 @@ class Epp::Domain < Domain
domain = Epp::Domain.new
domain.attributes = domain.attrs_from(frame, current_user)
domain.attach_default_contacts
- domain.registered_at = Time.zone.now
period = domain.period.to_i
plural_period_unit_name = (domain.period_unit == 'm' ? 'months' : 'years').to_sym
@@ -150,7 +149,6 @@ class Epp::Domain < Domain
at[:name] = frame.css('name').text if new_record?
at[:registrar_id] = current_user.registrar.try(:id)
- at[:registered_at] = Time.zone.now if new_record?
period = frame.css('period').text
at[:period] = (period.to_i == 0) ? 1 : period.to_i
diff --git a/app/models/whois_record.rb b/app/models/whois_record.rb
index 4994283c9..3563b9630 100644
--- a/app/models/whois_record.rb
+++ b/app/models/whois_record.rb
@@ -36,7 +36,7 @@ class WhoisRecord < ApplicationRecord
h[:disclaimer] = disclaimer_text if disclaimer_text.present?
h[:name] = domain.name
h[:status] = domain.statuses.map { |x| status_map[x] || x }
- h[:registered] = domain.registered_at.try(:to_s, :iso8601)
+ h[:registered] = domain.registered_at.iso8601
h[:changed] = domain.updated_at.try(:to_s, :iso8601)
h[:expire] = domain.valid_to.to_date.to_s
h[:outzone] = domain.outzone_at.try(:to_date).try(:to_s)
diff --git a/app/views/admin/domains/partials/_general.html.erb b/app/views/admin/domains/partials/_general.html.erb
index 0151094b9..dd99d45b8 100644
--- a/app/views/admin/domains/partials/_general.html.erb
+++ b/app/views/admin/domains/partials/_general.html.erb
@@ -10,7 +10,7 @@
<%= t(:name) %>
<%= @domain.name %>
- <%= t(:registered_at) %>
+ <%= Domain.human_attribute_name :registered_at %>
<%= l(@domain.registered_at) %>
<%= t(:registrar_name) %>
diff --git a/app/views/registrant/domains/partials/_general.html.erb b/app/views/registrant/domains/partials/_general.html.erb
index d79980797..38995be01 100644
--- a/app/views/registrant/domains/partials/_general.html.erb
+++ b/app/views/registrant/domains/partials/_general.html.erb
@@ -10,7 +10,7 @@
<%= t(:name) %>
<%= @domain.name %>
- <%= t(:registered_at) %>
+ <%= Domain.human_attribute_name :registered_at %>
<%= l(@domain.registered_at) %>
<%= Registrar.model_name.human %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 27299072e..0a45c83ba 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -195,7 +195,6 @@ en:
registrar_name: 'Registrar'
owner: 'Registrant'
domain_details: 'Domain details'
- registered_at: 'Registered at'
password: 'Password'
valid_from: 'Valid from'
general: 'General'
diff --git a/db/migrate/20191217013225_remove_domains_registered_at.rb b/db/migrate/20191217013225_remove_domains_registered_at.rb
new file mode 100644
index 000000000..458c5ebda
--- /dev/null
+++ b/db/migrate/20191217013225_remove_domains_registered_at.rb
@@ -0,0 +1,5 @@
+class RemoveDomainsRegisteredAt < ActiveRecord::Migration[5.0]
+ def change
+ remove_column :domains, :registered_at
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index 377259100..6224671ad 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -778,7 +778,6 @@ CREATE TABLE public.domains (
id integer NOT NULL,
name character varying NOT NULL,
registrar_id integer NOT NULL,
- registered_at timestamp without time zone,
valid_to timestamp without time zone NOT NULL,
registrant_id integer NOT NULL,
transfer_code character varying NOT NULL,
@@ -4828,6 +4827,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20191203083643'),
('20191206183853'),
('20191212133136'),
+('20191217013225'),
('20191219112434'),
('20191219124429'),
('20191227110904'),
diff --git a/test/fixtures/domains.yml b/test/fixtures/domains.yml
index 87059e68a..c8ea1bfce 100644
--- a/test/fixtures/domains.yml
+++ b/test/fixtures/domains.yml
@@ -5,7 +5,6 @@ shop:
registrar: bestnames
registrant: john
transfer_code: 65078d5
- registered_at: <%= Time.zone.parse('2010-07-04').to_s(:db) %>
valid_to: <%= Time.zone.parse('2010-07-05').to_s(:db) %>
outzone_at: <%= Time.zone.parse('2010-07-06').to_s(:db) %>
delete_date: 2010-07-07
diff --git a/test/models/domain_test.rb b/test/models/domain_test.rb
index ec6f60c52..b4a1d7b47 100644
--- a/test/models/domain_test.rb
+++ b/test/models/domain_test.rb
@@ -425,6 +425,12 @@ class DomainTest < ActiveSupport::TestCase
assert_not(@domain.force_delete_scheduled?)
end
+ def test_aliases_registered_at_to_created_at
+ created_at = Time.zone.parse('2010-07-05 10:00')
+ domain = Domain.new(created_at: created_at)
+ assert_equal created_at, domain.registered_at
+ end
+
private
def valid_domain
diff --git a/test/system/registrant_area/domains/details_test.rb b/test/system/registrant_area/domains/details_test.rb
index 5b2e30ba3..2f61d46be 100644
--- a/test/system/registrant_area/domains/details_test.rb
+++ b/test/system/registrant_area/domains/details_test.rb
@@ -12,7 +12,7 @@ class RegistrantAreaDomainDetailsTest < ApplicationSystemTestCase
visit registrant_domain_url(@domain)
assert_text 'Name shop.test'
- assert_text "Registered at #{l Time.zone.parse('2010-07-04')}"
+ assert_text "Registered at #{l @domain.registered_at}"
assert_link 'Best Names', href: registrant_registrar_path(@domain.registrar)
assert_text 'Transfer code'
@@ -73,4 +73,4 @@ class RegistrantAreaDomainDetailsTest < ApplicationSystemTestCase
assert_field nil, with: registrant_domain_update_confirm_url(@domain, token: 'a01')
end
-end
\ No newline at end of file
+end