From 1f70df9348a4fa742b9a039326493f4a076af6bd Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 12 Mar 2019 19:46:05 +0200 Subject: [PATCH 1/2] Fix WHOIS generation for domains at auction --- app/models/whois/record.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/whois/record.rb b/app/models/whois/record.rb index 943ae8b5a..5f6279247 100644 --- a/app/models/whois/record.rb +++ b/app/models/whois/record.rb @@ -8,6 +8,10 @@ module Whois def self.refresh(domain_name) if domain_name.at_auction? + # Remove original record since `Domain#update_whois_record` callback is disabled when + # domain is at auction + find_by(name: domain_name.to_s).try(:destroy!) + create!(name: domain_name, json: { name: domain_name.to_s, status: 'AtAuction', disclaimer: disclaimer }) From d646edf85c7e6aeebccc82895838e363b26ee59a Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 13 Mar 2019 12:43:38 +0200 Subject: [PATCH 2/2] Return array instead of string --- app/models/whois/record.rb | 4 ++-- test/models/whois/record_test.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/whois/record.rb b/app/models/whois/record.rb index 5f6279247..4c1b28aec 100644 --- a/app/models/whois/record.rb +++ b/app/models/whois/record.rb @@ -13,11 +13,11 @@ module Whois find_by(name: domain_name.to_s).try(:destroy!) create!(name: domain_name, json: { name: domain_name.to_s, - status: 'AtAuction', + status: ['AtAuction'], disclaimer: disclaimer }) elsif domain_name.awaiting_payment? || domain_name.pending_registration? find_by(name: domain_name.to_s).update!(json: { name: domain_name.to_s, - status: 'PendingRegistration', + status: ['PendingRegistration'], disclaimer: disclaimer }) else find_by(name: domain_name.to_s).destroy! diff --git a/test/models/whois/record_test.rb b/test/models/whois/record_test.rb index d4ca58e5c..f15868295 100644 --- a/test/models/whois/record_test.rb +++ b/test/models/whois/record_test.rb @@ -29,7 +29,7 @@ class Whois::RecordTest < ActiveSupport::TestCase whois_record = Whois::Record.last assert_equal 'some.test', whois_record.name assert_equal ({ 'name' => 'some.test', - 'status' => 'AtAuction', + 'status' => ['AtAuction'], 'disclaimer' => 'disclaimer' }), whois_record.json end @@ -45,7 +45,7 @@ class Whois::RecordTest < ActiveSupport::TestCase whois_record = Whois::Record.find_by(name: 'some.test') assert_equal 'some.test', whois_record.name assert_equal ({ 'name' => 'some.test', - 'status' => 'PendingRegistration', + 'status' => ['PendingRegistration'], 'disclaimer' => 'disclaimer' }), whois_record.json end @@ -61,7 +61,7 @@ class Whois::RecordTest < ActiveSupport::TestCase whois_record = Whois::Record.find_by(name: 'some.test') assert_equal 'some.test', whois_record.name assert_equal ({ 'name' => 'some.test', - 'status' => 'PendingRegistration', + 'status' => ['PendingRegistration'], 'disclaimer' => 'disclaimer' }), whois_record.json end end