Improve readability

#660
This commit is contained in:
Artur Beljajev 2018-01-26 01:01:27 +02:00
parent df2fa646d6
commit 3da7683949
2 changed files with 8 additions and 17 deletions

View file

@ -29,7 +29,6 @@ module Repp
else else
errors << { title: "#{domain_name} transfer code is wrong" } errors << { title: "#{domain_name} transfer code is wrong" }
end end
else else
errors << { title: "#{domain_name} does not exist" } errors << { title: "#{domain_name} does not exist" }
end end

View file

@ -3,6 +3,7 @@ require 'test_helper'
class DomainTransferTest < ActiveSupport::TestCase class DomainTransferTest < ActiveSupport::TestCase
def setup def setup
@domain = domains(:shop) @domain = domains(:shop)
@new_registrar = registrars(:goodnames)
end end
def test_invalid_without_transfer_code def test_invalid_without_transfer_code
@ -16,13 +17,13 @@ class DomainTransferTest < ActiveSupport::TestCase
refute_empty domain.transfer_code refute_empty domain.transfer_code
end end
def test_generated_transfer_code_is_random def test_random_transfer_code
domain = Domain.new domain = Domain.new
another_domain = Domain.new another_domain = Domain.new
refute_equal domain.transfer_code, another_domain.transfer_code refute_equal domain.transfer_code, another_domain.transfer_code
end end
def test_does_not_regenerate_transfer_code_if_domain_is_persisted def test_transfer_code_is_not_regenerated_on_update
original_transfer_code = @domain.transfer_code original_transfer_code = @domain.transfer_code
@domain.save! @domain.save!
@domain.reload @domain.reload
@ -35,35 +36,26 @@ class DomainTransferTest < ActiveSupport::TestCase
end end
def test_changes_registrar def test_changes_registrar
old_transfer_code = @domain.transfer_code @domain.transfer(@new_registrar)
new_registrar = registrars(:goodnames) assert_equal @new_registrar, @domain.registrar
@domain.transfer(new_registrar)
assert_equal new_registrar, @domain.registrar
refute_same @domain.transfer_code, old_transfer_code
end end
def test_regenerates_transfer_code def test_regenerates_transfer_code
old_transfer_code = @domain.transfer_code old_transfer_code = @domain.transfer_code
new_registrar = registrars(:goodnames) @domain.transfer(@new_registrar)
@domain.transfer(new_registrar)
refute_same @domain.transfer_code, old_transfer_code refute_same @domain.transfer_code, old_transfer_code
end end
def test_creates_domain_transfer def test_creates_domain_transfer
new_registrar = registrars(:goodnames)
assert_difference 'DomainTransfer.count' do assert_difference 'DomainTransfer.count' do
@domain.transfer(new_registrar) @domain.transfer(@new_registrar)
end end
end end
def test_copies_contacts def test_copies_contacts
new_registrar = registrars(:goodnames)
assert_difference 'Contact.count', 2 do assert_difference 'Contact.count', 2 do
@domain.transfer(new_registrar) @domain.transfer(@new_registrar)
end end
end end
end end