mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 08:52:04 +02:00
parent
cee51e1ac5
commit
0f6a47d73d
47 changed files with 644 additions and 640 deletions
29
test/models/registrar/code_test.rb
Normal file
29
test/models/registrar/code_test.rb
Normal 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
|
37
test/models/registrar/delete_test.rb
Normal file
37
test/models/registrar/delete_test.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DeleteRegistrarTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
@registrar = registrars(:not_in_use)
|
||||
end
|
||||
|
||||
def test_can_be_deleted_if_not_in_use
|
||||
assert_difference 'Registrar.count', -1 do
|
||||
@registrar.destroy
|
||||
end
|
||||
end
|
||||
|
||||
def test_cannot_be_deleted_if_has_at_least_one_user
|
||||
users(:api_bestnames).update!(registrar: @registrar)
|
||||
|
||||
assert_no_difference 'Registrar.count' do
|
||||
@registrar.destroy
|
||||
end
|
||||
end
|
||||
|
||||
def test_cannot_be_deleted_if_has_at_least_one_contact
|
||||
contacts(:john).update!(registrar: @registrar)
|
||||
|
||||
assert_no_difference 'Registrar.count' do
|
||||
@registrar.destroy
|
||||
end
|
||||
end
|
||||
|
||||
def test_cannot_be_deleted_if_has_at_least_one_domain
|
||||
domains(:shop).update!(registrar: @registrar)
|
||||
|
||||
assert_no_difference 'Registrar.count' do
|
||||
@registrar.destroy
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue