Skip to content

Commit

Permalink
Merge pull request #48 from internetee/auction-integration
Browse files Browse the repository at this point in the history
Add auction statuses
  • Loading branch information
vohmar authored Mar 25, 2019
2 parents 11124b5 + 42f8e3d commit c236092
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/models/whois_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ class WhoisRecord < ActiveRecord::Base
BLOCKED = 'Blocked'.freeze
RESERVED = 'Reserved'.freeze
DISCARDED = 'deleteCandidate'.freeze
AT_AUCTION = 'AtAuction'.freeze
PENDING_REGISTRATION = 'PendingRegistration'.freeze

TEMPLATE_DIR = File.join(File.dirname(__FILE__), '../views/whois_record/').freeze
DISCARDED_TEMPLATE = (TEMPLATE_DIR + "discarded.erb").freeze
TEMPLATE_INACTIVE = (TEMPLATE_DIR + "inactive.erb").freeze
LEGAL_PERSON_TEMPLATE = (TEMPLATE_DIR + "legal_person.erb").freeze
PRIVATE_PERSON_TEMPLATE = (TEMPLATE_DIR + "private_person.erb").freeze

Expand All @@ -17,10 +19,10 @@ def unix_body
end

def template
if discarded_blocked_or_reserved?
DISCARDED_TEMPLATE
else
if active?
private_or_legal_person_template
else
TEMPLATE_INACTIVE
end
end

Expand Down Expand Up @@ -60,7 +62,7 @@ def private_or_legal_person_template
end
end

def discarded_blocked_or_reserved?
!(([BLOCKED, RESERVED, DISCARDED] & json['status']).empty?)
def active?
(([BLOCKED, RESERVED, DISCARDED, AT_AUCTION, PENDING_REGISTRATION] & json['status']).empty?)
end
end
File renamed without changes.
11 changes: 11 additions & 0 deletions test/models/at_auction_record_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require_relative '../test_helper'
require_relative '../../app/models/whois_record'

class WhoisRecordAtAuctionTest < Minitest::Test
def setup
super

end


end
39 changes: 39 additions & 0 deletions test/models/whois_record_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,43 @@ def test_deserializes_tech_contacts
assert_equal 'Jack', contact.name
assert_equal %w[one], contact.disclosed_attributes
end

def test_returns_inactive_record_unix_body_when_domain_is_at_auction
@whois_record = WhoisRecord.new(name: 'shop.test', json: { name: 'shop.test',
status: [WhoisRecord::AT_AUCTION] })

expected_output = begin
"Estonia .ee Top Level Domain WHOIS server\n" \
"\n" \
"Domain:\n" \
"name: shop.test\n" \
"status: AtAuction\n" \
"\n" \
"Estonia .ee Top Level Domain WHOIS server\n" \
"More information at http://internet.ee\n" \
""
end

assert_equal expected_output, @whois_record.unix_body
end

def test_returns_inactive_record_unix_body_when_domain_is_pending_registration
@whois_record = WhoisRecord.new(name: 'shop.test',
json: { name: 'shop.test',
status: [WhoisRecord::PENDING_REGISTRATION] })

expected_output = begin
"Estonia .ee Top Level Domain WHOIS server\n" \
"\n" \
"Domain:\n" \
"name: shop.test\n" \
"status: PendingRegistration\n" \
"\n" \
"Estonia .ee Top Level Domain WHOIS server\n" \
"More information at http://internet.ee\n" \
""
end

assert_equal expected_output, @whois_record.unix_body
end
end

0 comments on commit c236092

Please sign in to comment.