mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 07:04:47 +02:00
parent
cee51e1ac5
commit
0f6a47d73d
47 changed files with 644 additions and 640 deletions
30
test/integration/admin/registrars/delete_test.rb
Normal file
30
test/integration/admin/registrars/delete_test.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
require 'test_helper'
|
||||
|
||||
class AdminAreaDeleteRegistrarTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
login_as users(:admin)
|
||||
end
|
||||
|
||||
def test_can_be_deleted_when_not_in_use
|
||||
visit admin_registrar_url(registrars(:not_in_use))
|
||||
|
||||
assert_difference 'Registrar.count', -1 do
|
||||
click_link_or_button 'Delete'
|
||||
end
|
||||
|
||||
assert_current_path admin_registrars_path
|
||||
assert_text 'Registrar has been successfully deleted'
|
||||
end
|
||||
|
||||
def test_cannot_be_deleted_when_in_use
|
||||
registrar = registrars(:bestnames)
|
||||
visit admin_registrar_url(registrar)
|
||||
|
||||
assert_no_difference 'Registrar.count' do
|
||||
click_link_or_button 'Delete'
|
||||
end
|
||||
|
||||
assert_current_path admin_registrar_path(registrar)
|
||||
assert_text 'Cannot delete record because dependent domains exist'
|
||||
end
|
||||
end
|
|
@ -1,17 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EditRegistrarTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
login_as users(:admin)
|
||||
@registrar = registrars(:bestnames)
|
||||
end
|
||||
|
||||
def test_updates_registrar
|
||||
visit admin_registrar_path(@registrar)
|
||||
click_link_or_button 'Edit'
|
||||
click_link_or_button 'Update registrar'
|
||||
|
||||
assert_current_path admin_registrar_path(@registrar)
|
||||
assert_text 'Registrar has been successfully updated'
|
||||
end
|
||||
end
|
69
test/integration/admin/registrars/edit_test.rb
Normal file
69
test/integration/admin/registrars/edit_test.rb
Normal file
|
@ -0,0 +1,69 @@
|
|||
require 'test_helper'
|
||||
|
||||
class AdminAreaEditRegistrarTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
login_as users(:admin)
|
||||
@registrar = registrars(:bestnames)
|
||||
end
|
||||
|
||||
def test_attributes_update
|
||||
visit admin_registrar_path(@registrar)
|
||||
click_link_or_button 'Edit'
|
||||
|
||||
fill_in 'Name', with: 'new name'
|
||||
fill_in 'Reg no', with: '4727673'
|
||||
fill_in 'Contact phone', with: '2570937'
|
||||
fill_in 'Website', with: 'http://new.example.com'
|
||||
fill_in 'Contact e-mail', with: 'new@example.com'
|
||||
|
||||
fill_in 'Street', with: 'new street'
|
||||
fill_in 'Zip', with: 'new zip'
|
||||
fill_in 'City', with: 'new city'
|
||||
fill_in 'State / Province', with: 'new state'
|
||||
select 'Germany', from: 'Country'
|
||||
|
||||
fill_in 'VAT number', with: '2386449'
|
||||
fill_in 'Accounting customer code', with: '866477'
|
||||
fill_in 'Billing email', with: 'new-billing@example.com'
|
||||
|
||||
select 'Estonian', from: 'Language'
|
||||
click_link_or_button 'Update registrar'
|
||||
|
||||
@registrar.reload
|
||||
assert_equal 'new name', @registrar.name
|
||||
assert_equal '4727673', @registrar.reg_no
|
||||
assert_equal '2570937', @registrar.phone
|
||||
assert_equal 'http://new.example.com', @registrar.website
|
||||
assert_equal 'new@example.com', @registrar.email
|
||||
|
||||
assert_equal 'new street', @registrar.street
|
||||
assert_equal 'new zip', @registrar.zip
|
||||
assert_equal 'new city', @registrar.city
|
||||
assert_equal 'new state', @registrar.state
|
||||
assert_equal Country.new('DE'), @registrar.country
|
||||
|
||||
assert_equal '2386449', @registrar.vat_no
|
||||
assert_equal '866477', @registrar.accounting_customer_code
|
||||
assert_equal 'new-billing@example.com', @registrar.billing_email
|
||||
|
||||
assert_equal 'et', @registrar.language
|
||||
assert_current_path admin_registrar_path(@registrar)
|
||||
assert_text 'Registrar has been successfully updated'
|
||||
end
|
||||
|
||||
def test_code_cannot_be_changed
|
||||
visit admin_registrar_path(@registrar)
|
||||
click_link_or_button 'Edit'
|
||||
assert_no_field 'Code'
|
||||
end
|
||||
|
||||
def test_fails_gracefully
|
||||
visit admin_registrar_path(@registrar)
|
||||
click_link_or_button 'Edit'
|
||||
fill_in 'Name', with: 'Good Names'
|
||||
click_link_or_button 'Update registrar'
|
||||
|
||||
assert_field 'Name', with: 'Good Names'
|
||||
assert_text 'Name has already been taken'
|
||||
end
|
||||
end
|
|
@ -1,23 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class NewRegistrarTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
login_as users(:admin)
|
||||
end
|
||||
|
||||
def test_creates_registrar
|
||||
visit admin_registrars_path
|
||||
click_link_or_button 'New registrar'
|
||||
|
||||
fill_in 'registrar[name]', with: 'John Doe'
|
||||
fill_in 'registrar[reg_no]', with: '1234567'
|
||||
fill_in 'registrar[email]', with: 'test@test.com'
|
||||
fill_in 'registrar[code]', with: 'test'
|
||||
fill_in 'registrar[accounting_customer_code]', with: 'test'
|
||||
click_link_or_button 'Create registrar'
|
||||
|
||||
assert_current_path admin_registrar_path(Registrar.last)
|
||||
assert_text 'Registrar has been successfully created'
|
||||
assert_text 'John Doe'
|
||||
end
|
||||
end
|
49
test/integration/admin/registrars/new_test.rb
Normal file
49
test/integration/admin/registrars/new_test.rb
Normal file
|
@ -0,0 +1,49 @@
|
|||
require 'test_helper'
|
||||
|
||||
class AdminAreaNewRegistrarTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
login_as users(:admin)
|
||||
end
|
||||
|
||||
def test_new_registrar_creation_with_required_params
|
||||
visit admin_registrars_url
|
||||
click_link_or_button 'New registrar'
|
||||
|
||||
fill_in 'Name', with: 'Brand new names'
|
||||
fill_in 'Reg no', with: '55555555'
|
||||
fill_in 'Contact e-mail', with: 'test@example.com'
|
||||
fill_in 'Accounting customer code', with: 'test'
|
||||
fill_in 'Code', with: 'test'
|
||||
|
||||
assert_difference 'Registrar.count' do
|
||||
click_link_or_button 'Create registrar'
|
||||
end
|
||||
|
||||
assert_current_path admin_registrar_path(Registrar.last)
|
||||
assert_text 'Registrar has been successfully created'
|
||||
end
|
||||
|
||||
def test_fails_gracefully
|
||||
visit admin_registrars_url
|
||||
click_link_or_button 'New registrar'
|
||||
|
||||
fill_in 'Name', with: 'Best Names'
|
||||
fill_in 'Reg no', with: '55555555'
|
||||
fill_in 'Contact e-mail', with: 'test@example.com'
|
||||
fill_in 'Accounting customer code', with: 'test'
|
||||
fill_in 'Code', with: 'test'
|
||||
|
||||
assert_no_difference 'Registrar.count' do
|
||||
click_link_or_button 'Create registrar'
|
||||
end
|
||||
assert_field 'Name', with: 'Best Names'
|
||||
assert_text 'Name has already been taken'
|
||||
end
|
||||
|
||||
def test_pre_populated_default_language
|
||||
Setting.default_language = 'en'
|
||||
visit admin_registrars_url
|
||||
click_link_or_button 'New registrar'
|
||||
assert_field 'Language', with: 'en'
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue