Refactor registrars

#765
This commit is contained in:
Artur Beljajev 2017-11-20 08:10:59 +02:00
parent cee51e1ac5
commit 0f6a47d73d
47 changed files with 644 additions and 640 deletions

View file

@ -0,0 +1,29 @@
require 'test_helper'
class RegistrarCodeTest < ActiveSupport::TestCase
def setup
@registrar = registrars(:bestnames).dup
end
def test_registrar_is_invalid_without_code
@registrar.code = ''
assert @registrar.invalid?
end
def test_special_code_validation
@registrar.code = 'CID'
assert @registrar.invalid?
assert_includes @registrar.errors.full_messages, 'Code is forbidden'
end
def test_cannot_be_changed_once_registrar_is_created
registrar = registrars(:bestnames)
registrar.update!(code: 'new-code')
refute_equal 'new-code', registrar.code
end
def test_normalization
@registrar.code = 'with spaces:and:colon.'
assert_equal 'WITHSPACESANDCOLON.', @registrar.code
end
end