Skip to content

Commit

Permalink
Merge pull request #226 from internetee/29-disputed-status
Browse files Browse the repository at this point in the history
Test disputed, allow reserved state for both active/inactive domain names
  • Loading branch information
vohmar authored May 22, 2020
2 parents 4184705 + 26b5864 commit 767f4e1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
6 changes: 5 additions & 1 deletion app/models/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ class Domain
STATUS_DISCARDED = 'deleteCandidate'.freeze
STATUS_AT_AUCTION = 'AtAuction'.freeze
STATUS_PENDING_REGISTRATION = 'PendingRegistration'.freeze
STATUS_DISPUTED = 'Disputed'.freeze

INACTIVE_STATUSES = [STATUS_BLOCKED, STATUS_RESERVED, STATUS_DISCARDED,
INACTIVE_STATUSES = [STATUS_BLOCKED, STATUS_DISCARDED,
STATUS_AT_AUCTION, STATUS_PENDING_REGISTRATION].freeze

private_constant :INACTIVE_STATUSES

attr_accessor :name
Expand All @@ -21,6 +23,8 @@ class Domain
attr_accessor :registration_deadline

def active?
return false if registered.blank?

(statuses & INACTIVE_STATUSES).empty?
end
end
19 changes: 17 additions & 2 deletions test/models/domain_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_statuses
end

def test_active
domain = Domain.new(statuses: %w[ok])
domain = Domain.new(statuses: %w[ok], registered: Time.now)
assert domain.active?
end

Expand All @@ -22,11 +22,16 @@ def test_inactive_when_blocked

# A domain in `rest-whois` app can either be registered or reserved, but in general,
# a reserved domain _can_ be registered
def test_inactive_when_reserved
def test_inactive_when_reserved_and_unregistered
domain = Domain.new(statuses: [Domain::STATUS_RESERVED])
assert_not domain.active?
end

def test_active_when_reserved_and_registered
domain = Domain.new(statuses: [Domain::STATUS_RESERVED], registered: Time.now)
assert domain.active?
end

def test_inactive_when_discarded
domain = Domain.new(statuses: [Domain::STATUS_DISCARDED])
assert_not domain.active?
Expand All @@ -37,6 +42,16 @@ def test_inactive_when_at_auction
assert_not domain.active?
end

def test_inactive_when_disputed_and_unregistered
domain = Domain.new(statuses: [Domain::STATUS_DISPUTED])
assert_not domain.active?
end

def test_active_when_disputed_and_registered
domain = Domain.new(statuses: [Domain::STATUS_DISPUTED], registered: Time.now)
assert domain.active?
end

def test_inactive_when_pending_registration
domain = Domain.new(statuses: [Domain::STATUS_PENDING_REGISTRATION])
assert_not domain.active?
Expand Down
2 changes: 1 addition & 1 deletion test/system/contact_requests_confirmation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_en_locale_in_confirmation_form
visit(new_contact_request_path(params: { domain_name: 'privatedomain.test' }))
text = begin
'You will receive an one time link to confirm your email, and then send a message to the owner or administrator ' \
"of the domain. " \
'of the domain. ' \
'The link expires in 24 hours.'
end

Expand Down

0 comments on commit 767f4e1

Please sign in to comment.