Skip to content

Commit

Permalink
Merge pull request #235 from internetee/fix-registration-deadline-format
Browse files Browse the repository at this point in the history
Fix date format
  • Loading branch information
vohmar authored Jun 3, 2020
2 parents 9d25120 + 565ef54 commit 47709f1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/models/whois_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def deserialize_domain
expire: json['expire'],
outzone: json['outzone'],
delete: json['delete'],
registration_deadline: json['registration_deadline'].try(:to_s, :iso8601))
registration_deadline: json['registration_deadline']
.try(:to_datetime)
.try(:to_s, :iso8601))
end
# rubocop:enable Metrics/AbcSize

Expand Down
16 changes: 16 additions & 0 deletions test/models/whois_record_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ def test_deserializes_domain
assert_equal Time.zone.parse('2010-07-09'), whois_record.domain.registration_deadline
end

def test_deserializes_domain_with_old_reg_deadline_format
whois_record = WhoisRecord.new(json: { name: 'shop.test',
status: %w[active],
registered: '2010-07-05T00:00:00+00:00',
changed: '2010-07-06T00:00:00+00:00',
expire: '2010-07-07T00:00:00+00:00',
outzone: '2010-07-08T00:00:00+00:00',
delete: '2010-07-09T00:00:00+00:00',
registration_deadline: '2020-06-09 23:59:59 +0300'})

assert_equal 'shop.test', whois_record.domain.name
assert_equal %w[active], whois_record.domain.statuses
assert_equal Time.parse('2020-06-09 23:59:59 +0300').try(:to_datetime).try(:to_s, :iso8601),
whois_record.domain.registration_deadline
end

def test_deserializes_registrar
whois_record = WhoisRecord.new(json: { registrar: 'Bestnames',
registrar_website: 'https://bestnames.test',
Expand Down

0 comments on commit 47709f1

Please sign in to comment.