Skip to content

Commit

Permalink
Merge pull request #702 from internetee/registry-701
Browse files Browse the repository at this point in the history
Bypass validation on contact transfers
  • Loading branch information
vohmar authored Feb 11, 2018
2 parents 77d0ba7 + 7997d34 commit cb2f327
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/concerns/contact/transferable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def transfer(new_registrar)
new_contact.regenerate_code
new_contact.regenerate_auth_info
new_contact.remove_address unless self.class.address_processing?
new_contact.save!
new_contact.save(validate: false)
new_contact
end

Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/contacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ acme_ltd:
ident_country_code: US
code: acme-ltd-001
auth_info: 720b3c

invalid:
name: any
code: any
auth_info: any
registrar: bestnames
4 changes: 4 additions & 0 deletions test/models/contact/contact_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ def setup
def test_validates
assert @contact.valid?
end

def test_invalid_fixture_is_invalid
assert contacts(:invalid).invalid?
end
end
8 changes: 8 additions & 0 deletions test/models/contact/contact_transfer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ def test_creates_new_contact
end
end

def test_bypasses_validation
@contact = contacts(:invalid)

assert_difference 'Contact.count' do
@contact.transfer(@new_registrar)
end
end

def test_changes_registrar
new_contact = @contact.transfer(@new_registrar)
assert_equal @new_registrar, new_contact.registrar
Expand Down

0 comments on commit cb2f327

Please sign in to comment.