Skip to content

Commit

Permalink
Merge pull request #1123 from internetee/skip-auction-for-blocked-and…
Browse files Browse the repository at this point in the history
…-reserved-domains

Skip auction for blocked and reserved domains
  • Loading branch information
vohmar authored Mar 22, 2019
2 parents ce1a5fd + e6405c5 commit 5d61cbf
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/concerns/domain/releasable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def releasable_domains
def release
if release_to_auction
transaction do
domain_name.sell_at_auction
domain_name.sell_at_auction if domain_name.auctionable?
destroy!
end
else
Expand Down
8 changes: 8 additions & 0 deletions app/models/dns/domain_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ def reserved?
ReservedDomain.where(name: name).any?
end

def auctionable?
!not_auctionable?
end

def to_s
name
end
Expand All @@ -77,6 +81,10 @@ def to_s

attr_reader :name

def not_auctionable?
blocked? || reserved?
end

def zone_with_same_origin?
DNS::Zone.where(origin: name).any?
end
Expand Down
18 changes: 18 additions & 0 deletions test/models/dns/domain_name_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,22 @@ def test_not_registered_when_domain_does_not_exist
assert domain_name.not_registered?
assert_not domain_name.registered?
end

def test_auctionable_when_not_blocked_or_reserved
domain_name = DNS::DomainName.new('shop.test')
assert_not domain_name.blocked?
assert_not domain_name.reserved?

assert domain_name.auctionable?
end

def test_not_auctionable_when_blocked
assert_equal 'blocked.test', blocked_domains(:one).name
assert_not DNS::DomainName.new('blocked.test').auctionable?
end

def test_not_auctionable_when_reserved
assert_equal 'reserved.test', reserved_domains(:one).name
assert_not DNS::DomainName.new('reserved.test').auctionable?
end
end
18 changes: 18 additions & 0 deletions test/models/domain/releasable/auctionable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ def test_sells_domain_at_auction
assert @domain.domain_name.at_auction?
end

def test_skips_auction_when_domains_is_blocked
assert_equal 'shop.test', @domain.name
blocked_domains(:one).update!(name: 'shop.test')

@domain.release

assert_not @domain.domain_name.at_auction?
end

def test_skips_auction_when_domains_is_reserved
assert_equal 'shop.test', @domain.name
reserved_domains(:one).update!(name: 'shop.test')

@domain.release

assert_not @domain.domain_name.at_auction?
end

def test_deletes_registered_domain
@domain.update!(delete_at: Time.zone.parse('2010-07-05 07:59'))
travel_to Time.zone.parse('2010-07-05 08:00')
Expand Down

0 comments on commit 5d61cbf

Please sign in to comment.