diff --git a/enom.gemspec b/enom.gemspec index af46fd8..835a93a 100644 --- a/enom.gemspec +++ b/enom.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "enom" - s.version = "1.1.7" + s.version = "1.1.8" s.authors = ["James Miller"] s.summary = %q{Ruby wrapper for the Enom API} s.description = %q{Enom is a Ruby wrapper and command line interface for portions of the Enom domain reseller API.} @@ -10,6 +10,7 @@ Gem::Specification.new do |s| s.has_rdoc = false s.add_dependency "httparty", "~> 0.10.0" s.add_dependency "public_suffix", "~> 1.5.3" + s.add_dependency "activesupport", "> 4.2" s.add_development_dependency "test-unit" s.add_development_dependency "shoulda" s.add_development_dependency "fakeweb" diff --git a/lib/enom/domain.rb b/lib/enom/domain.rb index c6fbe29..add50b3 100644 --- a/lib/enom/domain.rb +++ b/lib/enom/domain.rb @@ -1,3 +1,5 @@ +require 'active_support' +require 'active_support/core_ext/object/blank' require "public_suffix" module Enom @@ -175,9 +177,14 @@ def self.renew!(name, options = {}) sld, tld = parse_sld_and_tld(name) opts = {} opts.merge!("NumYears" => options[:years]) if options[:years] - response = Client.request({"Command" => "Extend", "SLD" => sld, "TLD" => tld}.merge(opts)) - Domain.find(name) - end + renew_response = Client.request({"Command" => "Extend", "SLD" => sld, "TLD" => tld}.merge(opts)) + domain = Domain.find(name) + # Enom doesn't make the new registration date immediately available in the find request, so we patch that + # value into the object. + registry_exp_date = renew_response.parsed_response['interface_response']['DomainInfo']['RegistryExpDate'] + domain.expiration_date = Date.strptime(registry_exp_date.split(" ").first, '%Y-%m-%d') + domain + end # Renew a domain that has already expired def self.update_expired!(name, years = 1) @@ -326,6 +333,10 @@ def expiration_date @expiration_date end + def expiration_date=(date) + @expiration_date = date + end + def registration_status get_extended_domain_attributes unless @registration_status return @registration_status diff --git a/test/domain_test.rb b/test/domain_test.rb index 5dfb8cd..c35318b 100644 --- a/test/domain_test.rb +++ b/test/domain_test.rb @@ -175,6 +175,11 @@ class DomainTest < Test::Unit::TestCase assert_kind_of Enom::Domain, @domain assert_equal @domain.name, "test123456test123456.com" end + + should "return the domain reflecting the new expiration date" do + original_expiration_date = Enom::Domain.find('test123456test123456.com').expiration_date + assert_true (@domain.expiration_date - original_expiration_date).to_i > 365 + end end context "renewing an expired domain" do diff --git a/test/test_helper.rb b/test/test_helper.rb index 6d872ff..8f54bd0 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -450,6 +450,9 @@ class Test::Unit::TestCase successful test123456test123456.com + + 2013-01-30 19:07:50.000 + 157609742 200 Command completed successfully