diff --git a/app/interactions/whois/update.rb b/app/interactions/whois/update.rb index e00824c44..7b84a46a6 100644 --- a/app/interactions/whois/update.rb +++ b/app/interactions/whois/update.rb @@ -8,12 +8,12 @@ module Whois def execute ::PaperTrail.request.whodunnit = "job - #{self.class.name} - #{type}" - klass = determine_class + collection = determine_collection Array(names).each do |name| - record = find_record(klass, name) + record = find_record(collection, name) if record - Whois::UpdateRecord.run(record: { klass: klass.to_s, id: record.id, type: type }) + Whois::UpdateRecord.run(record: { klass: collection.to_s, id: record.id, type: type }) else Whois::DeleteRecord.run(name: name, type: type) end @@ -22,7 +22,7 @@ module Whois private - def determine_class + def determine_collection case type when 'reserved' then ReservedDomain when 'blocked' then BlockedDomain @@ -32,8 +32,12 @@ module Whois end end - def find_record(klass, name) - klass == DNS::Zone ? klass.find_by(origin: name) : klass.find_by(name: name) + def find_record(collection, name) + if collection == Dispute.active + collection.find_by(domain_name: name) + else + collection == DNS::Zone ? collection.find_by(origin: name) : collection.find_by(name: name) + end end end end diff --git a/app/models/concerns/domain/disputable.rb b/app/models/concerns/domain/disputable.rb index a70d8b7cf..92c03f768 100644 --- a/app/models/concerns/domain/disputable.rb +++ b/app/models/concerns/domain/disputable.rb @@ -21,12 +21,16 @@ module Domain::Disputable @in_disputed_list ||= Dispute.active.find_by(domain_name: name).present? end + def in_auction_list? + @in_auction_list ||= Auction.find_by(domain: name, status: Auction.statuses[:started]).present? + end + def disputed? Dispute.active.where(domain_name: name).any? end def validate_disputed - return if persisted? || !in_disputed_list? + return if persisted? || !in_disputed_list? || in_auction_list? if reserved_pw.blank? errors.add(:base, :required_parameter_missing_disputed) diff --git a/test/integration/epp/domain/create/base_test.rb b/test/integration/epp/domain/create/base_test.rb index 63212d2fa..4932c6989 100644 --- a/test/integration/epp/domain/create/base_test.rb +++ b/test/integration/epp/domain/create/base_test.rb @@ -814,4 +814,42 @@ class EppDomainCreateBaseTest < EppTestCase assert_correct_against_schema response_xml assert_epp_response :billing_failure end + + def test_registers_disputed_domain_with_password + now = Time.zone.parse('2010-07-05') + travel_to now + disputed_domain = disputes(:active) + password = disputed_domain.password + + request_xml = <<-XML + + + + + + #{disputed_domain.domain_name} + #{contacts(:john).code} + + + + + #{'test' * 2000} + + #{password} + + + + + + XML + + assert_difference 'Domain.count' do + post epp_create_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + end + response_xml = Nokogiri::XML(response.body) + + assert_correct_against_schema response_xml + assert_epp_response :completed_successfully + end end