mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 17:01:44 +02:00
* Create new class called ApplicationIntegrationTest, so we don't have to override ActionDispatch::IntegrationTest * Move UI tests to inherit from ApplicationSystemTestCase * Existing REST API or EPP tests inherit from ApplicationIntegrationTest. * Move `require 'application_system_test_case'` at the end of `test_helper` I don't particularly agree with the Rails' convention of treating UI tests as system tests and API tests as integration tests, but I see no benefit in actively fighting against it.
50 lines
1.4 KiB
Ruby
50 lines
1.4 KiB
Ruby
require 'test_helper'
|
|
|
|
class AdminAreaNewRegistrarTest < ApplicationSystemTestCase
|
|
setup do
|
|
sign_in 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'
|
|
select 'United States', from: 'Country'
|
|
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
|