Skip to content

Commit c236092

Browse files
authored
Merge pull request #48 from internetee/auction-integration
Add auction statuses
2 parents 11124b5 + 42f8e3d commit c236092

File tree

4 files changed

+58
-6
lines changed

4 files changed

+58
-6
lines changed

app/models/whois_record.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ class WhoisRecord < ActiveRecord::Base
55
BLOCKED = 'Blocked'.freeze
66
RESERVED = 'Reserved'.freeze
77
DISCARDED = 'deleteCandidate'.freeze
8+
AT_AUCTION = 'AtAuction'.freeze
9+
PENDING_REGISTRATION = 'PendingRegistration'.freeze
810

911
TEMPLATE_DIR = File.join(File.dirname(__FILE__), '../views/whois_record/').freeze
10-
DISCARDED_TEMPLATE = (TEMPLATE_DIR + "discarded.erb").freeze
12+
TEMPLATE_INACTIVE = (TEMPLATE_DIR + "inactive.erb").freeze
1113
LEGAL_PERSON_TEMPLATE = (TEMPLATE_DIR + "legal_person.erb").freeze
1214
PRIVATE_PERSON_TEMPLATE = (TEMPLATE_DIR + "private_person.erb").freeze
1315

@@ -17,10 +19,10 @@ def unix_body
1719
end
1820

1921
def template
20-
if discarded_blocked_or_reserved?
21-
DISCARDED_TEMPLATE
22-
else
22+
if active?
2323
private_or_legal_person_template
24+
else
25+
TEMPLATE_INACTIVE
2426
end
2527
end
2628

@@ -60,7 +62,7 @@ def private_or_legal_person_template
6062
end
6163
end
6264

63-
def discarded_blocked_or_reserved?
64-
!(([BLOCKED, RESERVED, DISCARDED] & json['status']).empty?)
65+
def active?
66+
(([BLOCKED, RESERVED, DISCARDED, AT_AUCTION, PENDING_REGISTRATION] & json['status']).empty?)
6567
end
6668
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require_relative '../test_helper'
2+
require_relative '../../app/models/whois_record'
3+
4+
class WhoisRecordAtAuctionTest < Minitest::Test
5+
def setup
6+
super
7+
8+
end
9+
10+
11+
end

test/models/whois_record_test.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,43 @@ def test_deserializes_tech_contacts
2626
assert_equal 'Jack', contact.name
2727
assert_equal %w[one], contact.disclosed_attributes
2828
end
29+
30+
def test_returns_inactive_record_unix_body_when_domain_is_at_auction
31+
@whois_record = WhoisRecord.new(name: 'shop.test', json: { name: 'shop.test',
32+
status: [WhoisRecord::AT_AUCTION] })
33+
34+
expected_output = begin
35+
"Estonia .ee Top Level Domain WHOIS server\n" \
36+
"\n" \
37+
"Domain:\n" \
38+
"name: shop.test\n" \
39+
"status: AtAuction\n" \
40+
"\n" \
41+
"Estonia .ee Top Level Domain WHOIS server\n" \
42+
"More information at http://internet.ee\n" \
43+
""
44+
end
45+
46+
assert_equal expected_output, @whois_record.unix_body
47+
end
48+
49+
def test_returns_inactive_record_unix_body_when_domain_is_pending_registration
50+
@whois_record = WhoisRecord.new(name: 'shop.test',
51+
json: { name: 'shop.test',
52+
status: [WhoisRecord::PENDING_REGISTRATION] })
53+
54+
expected_output = begin
55+
"Estonia .ee Top Level Domain WHOIS server\n" \
56+
"\n" \
57+
"Domain:\n" \
58+
"name: shop.test\n" \
59+
"status: PendingRegistration\n" \
60+
"\n" \
61+
"Estonia .ee Top Level Domain WHOIS server\n" \
62+
"More information at http://internet.ee\n" \
63+
""
64+
end
65+
66+
assert_equal expected_output, @whois_record.unix_body
67+
end
2968
end

0 commit comments

Comments
 (0)