mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 13:36:15 +02:00
Merge pull request #2403 from internetee/exceptions-for-registered-domains-and-no-bids-auctions
added exception for auctions with no-bids and registred-domains statuses
This commit is contained in:
commit
4a31cc3b15
3 changed files with 65 additions and 9 deletions
|
@ -31,7 +31,7 @@ module Admin
|
|||
def create
|
||||
auction = Auction.new(domain: params[:domain], status: Auction.statuses[:started], platform: 'manual')
|
||||
|
||||
if domain_exists_in_blocked_disputed_and_registered?(params[:domain])
|
||||
if Auction.domain_exists_in_blocked_disputed_and_registered?(params[:domain])
|
||||
flash[:alert] = "Adding #{params[:domain]} failed - domain registered or regsitration is blocked"
|
||||
redirect_to admin_auctions_path and return
|
||||
end
|
||||
|
@ -81,7 +81,7 @@ module Admin
|
|||
table.each do |row|
|
||||
record = row.to_h
|
||||
|
||||
if domain_exists_in_blocked_disputed_and_registered?(record['name'])
|
||||
if Auction.domain_exists_in_blocked_disputed_and_registered?(record['name'])
|
||||
failed_names << record['name']
|
||||
|
||||
next
|
||||
|
@ -119,13 +119,6 @@ module Admin
|
|||
Epp::Domain.check_availability(domain_name)
|
||||
end
|
||||
|
||||
def domain_exists_in_blocked_disputed_and_registered?(domain_name)
|
||||
Domain.exists?(name: domain_name) ||
|
||||
BlockedDomain.exists?(name: domain_name) ||
|
||||
Dispute.exists?(domain_name: domain_name) ||
|
||||
Auction.exists?(domain: domain_name)
|
||||
end
|
||||
|
||||
def validate_table(table)
|
||||
first_row = table.headers
|
||||
first_row.include? 'name'
|
||||
|
|
|
@ -37,6 +37,24 @@ class Auction < ApplicationRecord
|
|||
find_by(domain: domain_name.to_s, status: PENDING_STATUSES)
|
||||
end
|
||||
|
||||
def self.domain_exists_in_blocked_disputed_and_registered?(domain_name)
|
||||
Domain.exists?(name: domain_name) ||
|
||||
BlockedDomain.exists?(name: domain_name) ||
|
||||
Dispute.exists?(domain_name: domain_name) ||
|
||||
exception_for_registred_or_unbided_existed_auctions(domain_name)
|
||||
end
|
||||
|
||||
def self.exception_for_registred_or_unbided_existed_auctions(domain_name)
|
||||
return false unless Auction.exists?(domain: domain_name)
|
||||
|
||||
auctions = Auction.where(domain: domain_name).order(:created_at)
|
||||
last_record = auctions.last
|
||||
|
||||
return false if last_record.domain_registered? || last_record.no_bids?
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
def start
|
||||
self.status = self.class.statuses[:started]
|
||||
save!
|
||||
|
|
|
@ -28,6 +28,51 @@ class AuctionTest < ActiveSupport::TestCase
|
|||
assert @auction.started?
|
||||
end
|
||||
|
||||
def test_auction_with_no_bids_dont_have_any_restriction
|
||||
@auction.update(status: :no_bids)
|
||||
@auction.reload
|
||||
|
||||
res = Auction.domain_exists_in_blocked_disputed_and_registered?(@auction.domain)
|
||||
refute res
|
||||
end
|
||||
|
||||
def test_auction_with_domain_registered_dont_have_any_restriction
|
||||
@auction.update(status: :domain_registered)
|
||||
@auction.reload
|
||||
|
||||
res = Auction.domain_exists_in_blocked_disputed_and_registered?(@auction.domain)
|
||||
refute res
|
||||
end
|
||||
|
||||
def test_auction_with_started_has_restriction
|
||||
@auction.update(status: :started)
|
||||
@auction.reload
|
||||
|
||||
res = Auction.domain_exists_in_blocked_disputed_and_registered?(@auction.domain)
|
||||
assert res
|
||||
end
|
||||
|
||||
def test_blocked_domain_has_restriction
|
||||
blocked_domain = blocked_domains(:one)
|
||||
|
||||
res = Auction.domain_exists_in_blocked_disputed_and_registered?(blocked_domain.name)
|
||||
assert res
|
||||
end
|
||||
|
||||
def test_dispute_domain_has_restriction
|
||||
dispute_domain = disputes(:active)
|
||||
|
||||
res = Auction.domain_exists_in_blocked_disputed_and_registered?(dispute_domain.domain_name)
|
||||
assert res
|
||||
end
|
||||
|
||||
def test_exist_domain_has_restriction
|
||||
domain = domains(:shop)
|
||||
|
||||
res = Auction.domain_exists_in_blocked_disputed_and_registered?(domain.name)
|
||||
assert res
|
||||
end
|
||||
|
||||
def test_pending
|
||||
domain_name = DNS::DomainName.new('auction.test')
|
||||
assert_equal 'auction.test', @auction.domain
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue