Merge branch 'master' into registry-790

# Conflicts:
#	test/integration/epp/domain/domain_delete_test.rb
#	test/integration/epp/domain/domain_update_test.rb
#	test/integration/epp/domain/transfer/request_test.rb
#	test/system/admin_area/domains_test.rb
This commit is contained in:
Artur Beljajev 2018-08-09 15:01:23 +03:00
commit 1d79f6548d
61 changed files with 731 additions and 84 deletions

View file

@ -0,0 +1,60 @@
require 'test_helper'
class ContactVersionsTest < ApplicationSystemTestCase
def setup
super
create_contact_with_history
sign_in users(:admin)
end
def teardown
super
delete_objects_once_done
end
def create_contact_with_history
sql = <<-SQL.squish
INSERT INTO registrars (id, name, reg_no, email, country_code, code,
accounting_customer_code, language)
VALUES (75, 'test_registrar', 'test123', 'test@test.com', 'EE', 'TEST123',
'test123', 'en');
INSERT INTO contacts (id, code, auth_info, registrar_id)
VALUES (75, 'test_code', '8b4d462aa04194ca78840a', 75);
INSERT INTO log_contacts (item_type, item_id, event, whodunnit, object,
object_changes, created_at, session, children, ident_updated_at, uuid)
VALUES ('Contact', 75, 'update', '1-AdminUser',
'{"id": 75, "code": "test_code", "auth_info": "8b4d462aa04194ca78840a", "registrar_id": 75, "old_field": "value"}',
'{"other_made_up_field": "value"}',
'2018-04-23 15:50:48.113491', '2018-04-23 12:44:56',
'{"legal_documents":[null]}', null, null
)
SQL
ActiveRecord::Base.connection.execute(sql)
end
def delete_objects_once_done
ActiveRecord::Base.connection.execute('DELETE from log_contacts where item_id = 75')
Domain.destroy_all
Contact.destroy_all
Registrar.destroy_all
end
def test_removed_fields_are_not_causing_errors_in_index_view
visit admin_contact_versions_path
assert_text 'test_registrar'
assert_text 'update 23.04.18, 18:50'
end
def test_removed_fields_are_not_causing_errors_in_details_view
version_id = Contact.find(75).versions.last
visit admin_contact_version_path(version_id)
assert_text 'test_registrar'
assert_text '23.04.18, 18:50 update 1-AdminUser'
end
end

View file

@ -0,0 +1,25 @@
require 'test_helper'
class AdminContactsTest < ApplicationSystemTestCase
def setup
super
@contact = contacts(:william)
sign_in users(:admin)
end
def test_display_list
visit admin_contacts_path
assert_text('william-001')
assert_text('william-002')
assert_text('acme-ltd-001')
end
def test_display_details
visit admin_contact_path(@contact)
assert_text('Street Main Street City New York Postcode 12345 ' \
'State New York Country United States of America')
end
end

View file

@ -0,0 +1,65 @@
require 'test_helper'
class DomainVersionsTest < ApplicationSystemTestCase
def setup
super
create_domain_with_history
sign_in users(:admin)
end
def teardown
super
delete_objects_once_done
end
def create_domain_with_history
sql = <<-SQL.squish
INSERT INTO registrars (id, name, reg_no, email, country_code, code,
accounting_customer_code, language)
VALUES (54, 'test_registrar', 'test123', 'test@test.com', 'EE', 'TEST123',
'test123', 'en');
INSERT INTO contacts (id, code, auth_info, registrar_id)
VALUES (54, 'test_code', '8b4d462aa04194ca78840a', 54);
INSERT INTO domains (id, registrar_id, valid_to, registrant_id,
transfer_code)
VALUES (54, 54, '2018-06-23T12:14:02.732+03:00', 54, 'transfer_code');
INSERT INTO log_domains (item_type, item_id, event, whodunnit, object,
object_changes, created_at, nameserver_ids, tech_contact_ids,
admin_contact_ids, session, children)
VALUES ('Domain', 54, 'update', '1-AdminUser',
'{"id": 54, "registrar_id": 54, "valid_to": "2018-07-23T12:14:05.583+03:00", "registrant_id": 54, "transfer_code": "transfer_code", "valid_from": "2017-07-23T12:14:05.583+03:00"}',
'{"foo": "bar", "other_made_up_field": "value"}',
'2018-04-23 15:50:48.113491', '{}', '{}', '{}', '2018-04-23 12:44:56',
'{"null_fracdmin_contacts":[108],"tech_contacts":[109],"nameservers":[],"dnskeys":[],"legal_documents":[null],"registrant":[1]}'
)
SQL
ActiveRecord::Base.connection.execute(sql)
end
def delete_objects_once_done
ActiveRecord::Base.connection.execute('DELETE FROM log_domains where item_id = 54')
Domain.destroy_all
Contact.destroy_all
Registrar.destroy_all
end
def test_removed_fields_are_not_causing_errors_in_index_view
visit admin_domain_versions_path
assert_text 'test_registrar'
assert_text 'test_registrar update 23.04.18, 18:50'
end
def test_removed_fields_are_not_causing_errors_in_details_view
version_id = Domain.find(54).versions.last
visit admin_domain_version_path(version_id)
assert_text 'test_registrar'
assert_text '23.04.18, 18:50 update 1-AdminUser'
end
end

View file

@ -0,0 +1,21 @@
require 'test_helper'
class AdminAreaDomainDetailsTest < ApplicationSystemTestCase
setup do
sign_in users(:admin)
@domain = domains(:shop)
end
def test_discarded_domain_has_corresponding_label
travel_to Time.zone.parse('2010-07-05 10:30')
@domain.delete_at = Time.zone.parse('2010-07-05 10:00')
visit admin_domain_url(@domain)
assert_no_css 'span.label.label-warning', text: 'deleteCandidate'
@domain.discard
visit admin_domain_url(@domain)
assert_css 'span.label.label-warning', text: 'deleteCandidate'
end
end

View file

@ -0,0 +1,58 @@
require 'test_helper'
class AdminAreaDomainForceDeleteTest < ApplicationSystemTestCase
include ActionMailer::TestHelper
setup do
sign_in users(:admin)
@domain = domains(:shop)
ActionMailer::Base.deliveries.clear
end
def test_schedules_domain_force_delete
refute @domain.force_delete_scheduled?
visit edit_admin_domain_url(@domain)
click_link_or_button 'Force delete domain'
@domain.reload
assert @domain.force_delete_scheduled?
assert_current_path edit_admin_domain_path(@domain)
assert_text 'Force delete procedure has been scheduled'
end
def test_notifies_registrar
assert_difference '@domain.registrar.messages.size' do
visit edit_admin_domain_url(@domain)
click_link_or_button 'Force delete domain'
end
end
def test_notifies_registrant_and_admin_contacts_by_email_by_default
assert_emails 1 do
visit edit_admin_domain_url(@domain)
click_link_or_button 'Force delete domain'
end
end
def test_allows_to_skip_notifying_registrant_and_admin_contacts_by_email
assert_no_emails do
visit edit_admin_domain_url(@domain)
uncheck 'notify_by_email'
click_link_or_button 'Force delete domain'
end
end
def test_cancels_scheduled_domain_force_delete
@domain.discard
@domain.schedule_force_delete
visit edit_admin_domain_url(@domain)
click_link_or_button 'Cancel force delete'
@domain.reload
refute @domain.force_delete_scheduled?
assert_current_path edit_admin_domain_path(@domain)
assert_text 'Force delete procedure has been cancelled'
end
end

View file

@ -0,0 +1,31 @@
require 'test_helper'
class AdminDomainsTestTest < ApplicationSystemTestCase
def setup
sign_in users(:admin)
@domain = domains(:shop)
end
def teardown
travel_back
end
def test_shows_details
visit admin_domain_path(@domain)
assert_field nil, with: @domain.transfer_code
end
def test_keep_a_domain
travel_to Time.zone.parse('2010-07-05 10:30')
@domain.delete_at = Time.zone.parse('2010-07-05 10:00')
@domain.discard
visit edit_admin_domain_url(@domain)
click_link_or_button 'Remove deleteCandidate status'
@domain.reload
assert_not @domain.discarded?
assert_text 'deleteCandidate status has been removed'
assert_no_link 'Remove deleteCandidate status'
end
end

View file

@ -0,0 +1,14 @@
require 'test_helper'
class AdminAreaNewMailTemplateTest < ApplicationSystemTestCase
setup do
sign_in users(:admin)
end
def test_new_mail_template_does_not_throw_template_error
visit admin_mail_templates_url
click_link_or_button 'New'
assert_text "HTML body"
assert_text "New mail template"
end
end

View file

@ -0,0 +1,30 @@
require 'test_helper'
class AdminAreaDeleteRegistrarTest < ApplicationSystemTestCase
setup do
sign_in 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

View file

@ -0,0 +1,18 @@
require 'test_helper'
class AdminAreaRegistrarDetailsTest < ApplicationSystemTestCase
include ActionView::Helpers::NumberHelper
setup do
sign_in users(:admin)
@registrar = registrars(:complete)
end
def test_registrar_details
visit admin_registrar_path(@registrar)
assert_text 'Accounting customer code US0001'
assert_text 'VAT number US12345'
assert_text 'VAT rate 5.0%'
assert_text 'Language English'
end
end

View file

@ -0,0 +1,69 @@
require 'test_helper'
class AdminAreaEditRegistrarTest < ApplicationSystemTestCase
setup do
sign_in 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

View file

@ -0,0 +1,50 @@
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