Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create whois records on domain release #1143

Merged
merged 4 commits into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/api/v1/auctions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def serializable_hash_for_update_action(auction)
end

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 = {}
end

Expand Down
5 changes: 4 additions & 1 deletion app/models/dns/domain_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ def pending_auction
end

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)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/whois/record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ def update_from_auction(auction)
end
end
end
end
end
10 changes: 5 additions & 5 deletions test/integration/epp/domain/create/auction_idn_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def teardown
Domain.release_to_auction = false
end

def test_registers_domain_with_ascii_idn_cannot_be_registered_without_registration_code
def test_domain_with_ascii_idn_cannot_be_registered_without_registration_code
@idn_auction.update!(status: Auction.statuses[:payment_received],
registration_code: "auction001")

Expand Down Expand Up @@ -53,7 +53,7 @@ def test_registers_domain_with_ascii_idn_cannot_be_registered_without_registrati
response_xml.at_css('result msg').text
end

def test_registers_domain_with_unicode_idn_cannot_be_registered_without_registration_code
def test_domain_with_unicode_idn_cannot_be_registered_without_registration_code
@idn_auction.update!(status: Auction.statuses[:payment_received],
registration_code: "auction001")

Expand Down Expand Up @@ -91,7 +91,7 @@ def test_registers_domain_with_unicode_idn_cannot_be_registered_without_registra
response_xml.at_css('result msg').text
end

def test_registers_domain_with_ascii_idn_cannot_be_registered_without_winning_the_auction
def test_domain_with_ascii_idn_cannot_be_registered_without_winning_the_auction
@idn_auction.started!

request_xml = <<-XML
Expand Down Expand Up @@ -128,7 +128,7 @@ def test_registers_domain_with_ascii_idn_cannot_be_registered_without_winning_th
response_xml.at_css('result msg').text
end

def test_registers_domain_with_unicode_idn_cannot_be_registered_without_winning_the_auction
def test_domain_with_unicode_idn_cannot_be_registered_without_winning_the_auction
@idn_auction.started!

request_xml = <<-XML
Expand Down Expand Up @@ -165,7 +165,7 @@ def test_registers_domain_with_unicode_idn_cannot_be_registered_without_winning_
response_xml.at_css('result msg').text
end

def test_registers_domain_with_unicode_idn_cannot_be_registered_without_winning_the_auction
def test_domain_with_unicode_idn_cannot_be_registered_without_winning_the_auction
@idn_auction.started!

request_xml = <<-XML
Expand Down
16 changes: 15 additions & 1 deletion test/models/dns/domain_name_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ def test_selling_at_auction_updates_whois
assert_equal Time.zone.parse('2010-07-05 10:00'), @whois_record.updated_at
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
domain_name = DNS::DomainName.new('auction.test')
auctions(:one).update!(domain: 'auction.test', status: Auction.statuses[:started])
Expand Down Expand Up @@ -162,4 +176,4 @@ def test_not_auctionable_when_reserved
assert_equal 'reserved.test', reserved_domains(:one).name
assert_not DNS::DomainName.new('reserved.test').auctionable?
end
end
end