Create whois records on releasing domain to auction

This commit is contained in:
Maciej Szlosarczyk 2019-04-03 15:14:10 +03:00
parent c85ebf542d
commit 4413a1bb27
No known key found for this signature in database
GPG key ID: 41D62D42D3B0D765
3 changed files with 20 additions and 3 deletions

View file

@ -52,7 +52,7 @@ module Api
end end
def update_whois_from_auction(auction) def update_whois_from_auction(auction)
whois_record = Whois::Record.find_or_create_by(name: auction.domain) do |record| whois_record = Whois::Record.find_or_create_by!(name: auction.domain) do |record|
record.json = {} record.json = {}
end end

View file

@ -92,7 +92,10 @@ module DNS
end end
def update_whois_from_auction(auction) def update_whois_from_auction(auction)
whois_record = Whois::Record.find_by!(name: name) whois_record = Whois::Record.find_or_create_by!(name: name) do |record|
record.json = {}
end
whois_record.update_from_auction(auction) whois_record.update_from_auction(auction)
end end
end end

View file

@ -92,6 +92,20 @@ class DNS::DomainNameTest < ActiveSupport::TestCase
assert_equal Time.zone.parse('2010-07-05 10:00'), @whois_record.updated_at assert_equal Time.zone.parse('2010-07-05 10:00'), @whois_record.updated_at
end end
def test_selling_at_auction_creates_whois_record
travel_to Time.zone.parse('2010-07-05 10:00')
domain_name = DNS::DomainName.new('new-auction.test')
domain_name.sell_at_auction
whois_record = Whois::Record.find_by(name: 'new-auction.test')
assert whois_record
assert_equal Time.zone.parse('2010-07-05 10:00'), whois_record.updated_at
assert_equal Time.zone.parse('2010-07-05 10:00'), whois_record.created_at
assert_equal ['AtAuction'], whois_record.json['status']
end
def test_at_auction def test_at_auction
domain_name = DNS::DomainName.new('auction.test') domain_name = DNS::DomainName.new('auction.test')
auctions(:one).update!(domain: 'auction.test', status: Auction.statuses[:started]) auctions(:one).update!(domain: 'auction.test', status: Auction.statuses[:started])
@ -162,4 +176,4 @@ class DNS::DomainNameTest < ActiveSupport::TestCase
assert_equal 'reserved.test', reserved_domains(:one).name assert_equal 'reserved.test', reserved_domains(:one).name
assert_not DNS::DomainName.new('reserved.test').auctionable? assert_not DNS::DomainName.new('reserved.test').auctionable?
end end
end end