diff --git a/app/models/domain.rb b/app/models/domain.rb index b57a2c44b..f8a693028 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -80,7 +80,7 @@ class Domain < ActiveRecord::Base after_create :update_reserved_domains def update_reserved_domains - return unless reserved? + return unless in_reserved_list? rd = ReservedDomain.first rd.names[name] = SecureRandom.hex rd.save @@ -95,7 +95,7 @@ class Domain < ActiveRecord::Base validate :validate_reservation def validate_reservation return if persisted? - return if !reserved? || reserved_pw == auth_info + return if !in_reserved_list? || reserved_pw == auth_info errors.add(:base, :domain_is_reserved_and_requires_correct_auth_info) end @@ -261,7 +261,7 @@ class Domain < ActiveRecord::Base @registrant_typeahead || registrant.try(:name) || nil end - def reserved? + def in_reserved_list? reserved_pw.present? end @@ -515,7 +515,7 @@ class Domain < ActiveRecord::Base end def manage_automatic_statuses - statuses << DomainStatus::RESERVED if new_record? && reserved? + statuses << DomainStatus::RESERVED if new_record? && in_reserved_list? # domain_statuses.create(value: DomainStatus::DELETE_CANDIDATE) if delete_candidateable? if statuses.empty? && valid? diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index deb707da1..ebcbedd68 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -1490,6 +1490,33 @@ describe 'EPP Domain', epp: true do d.pending_update?.should == false end + it 'should keep reserved status after reserved domain update' do + domain.statuses = ['reserved'] + domain.save + + xml_params = { + name: { value: domain.name }, + chg: [ + registrant: { value: 'FIXED:CITIZEN_1234', attrs: { verified: 'yes' } } + ] + } + + response = epp_plain_request(domain_update_xml(xml_params, {}, { + _anonymus: [ + legalDocument: { + value: 'dGVzdCBmYWlsCg==', + attrs: { type: 'pdf' } + } + ] + })) + + response[:results][0][:msg].should == 'Command completed successfully' + response[:results][0][:result_code].should == '1000' + + d = Domain.last + d.statuses.should match_array(['reserved']) + end + it 'updates a domain' do existing_pw = domain.auth_info