Merge branch 'master' into 499-admin-wildcard-search

This commit is contained in:
Thiago Youssef 2022-04-05 14:18:04 +03:00
parent f93286c2e6
commit fd6e625d25
49 changed files with 382 additions and 160 deletions

4
test/fixtures/files/accounts.csv vendored Normal file
View file

@ -0,0 +1,4 @@
Id,Balance,Currency,Registrar
112846265,100.0,EUR,Best Names
298486374,100.0,EUR,Good Names
597560588,0.0,EUR,Not in use
1 Id Balance Currency Registrar
2 112846265 100.0 EUR Best Names
3 298486374 100.0 EUR Good Names
4 597560588 0.0 EUR Not in use

View file

@ -0,0 +1,3 @@
Name,ID,Ident,Registrar,Action,Created at
,test_code,[ ],Best Names,update,2018-04-23 15:50:48
,,[ ],,update,2010-07-04 21:00:00
1 Name ID Ident Registrar Action Created at
2 test_code [ ] Best Names update 2018-04-23 15:50:48
3 [ ] update 2010-07-04 21:00:00

2
test/fixtures/files/contacts.csv vendored Normal file
View file

@ -0,0 +1,2 @@
Name,ID,Ident,E-mail,Created at,Registrar,Phone
Acme Ltd,acme-ltd-001,1234567 [US org],acme@outlook.test,2010-07-05 07:30:00,Best Names,+555.555
1 Name ID Ident E-mail Created at Registrar Phone
2 Acme Ltd acme-ltd-001 1234567 [US org] acme@outlook.test 2010-07-05 07:30:00 Best Names +555.555

View file

@ -0,0 +1,3 @@
Name,Registrant,Registrar,Action,Created at
,test_code,Best Names,update,2018-04-23 15:50:48
,John,,update,2010-07-04 21:00:00
1 Name Registrant Registrar Action Created at
2 test_code Best Names update 2018-04-23 15:50:48
3 John update 2010-07-04 21:00:00

2
test/fixtures/files/domains.csv vendored Normal file
View file

@ -0,0 +1,2 @@
Domain,Registrant,Valid to,Registrar,Created at,Statuses,Contacts code,Force delete date,Force delete data
metro.test,Jack,2010-07-05 00:00:00,Good Names,2010-07-05 07:30:00,[],"[""jack-001"", ""jack-001""]",,
1 Domain Registrant Valid to Registrar Created at Statuses Contacts code Force delete date Force delete data
2 metro.test Jack 2010-07-05 00:00:00 Good Names 2010-07-05 07:30:00 [] ["jack-001", "jack-001"]

3
test/fixtures/files/invoices.csv vendored Normal file
View file

@ -0,0 +1,3 @@
Number,Buyer,Due Date,Receipt Date,Issue Date,Total,Currency,Seller Name
2,Best Names,2010-07-06,Unpaid,2010-07-05,16.5,EUR,Seller Ltd
1,Best Names,2010-07-06,2010-07-05,2010-07-05,16.5,EUR,Seller Ltd
1 Number Buyer Due Date Receipt Date Issue Date Total Currency Seller Name
2 2 Best Names 2010-07-06 Unpaid 2010-07-05 16.5 EUR Seller Ltd
3 1 Best Names 2010-07-06 2010-07-05 2010-07-05 16.5 EUR Seller Ltd

View file

@ -41,10 +41,8 @@ class RegistrantUserTest < ActiveSupport::TestCase
company = Company.new(org.ident, "ace")
company_register = Minitest::Mock.new
company_register.expect(:representation_rights, [company], [{ citizen_personal_code: '1234',
citizen_country_code: 'USA' }])
@user.companies(company_register)
Spy.on(@user, :companies).and_return([company])
@user.update_company_contacts
org.reload
assert_equal org.name, company.company_name
@ -63,6 +61,39 @@ class RegistrantUserTest < ActiveSupport::TestCase
company_register.verify
end
def test_should_return_zero_count_of_companies
assert_equal 'US-1234', @user.registrant_ident
org = contacts(:acme_ltd)
org.ident_country_code = 'EE'
org.save(validate: false)
org.reload
company_one = Company.new(org.ident, 'Acme Ltd')
Spy.on(@user, :companies).and_return([company_one])
response = @user.do_need_update_contact?
org.reload
assert_equal response[:counter], 0
end
def test_should_return_count_of_contact_which_should_be_updated
assert_equal 'US-1234', @user.registrant_ident
org = contacts(:acme_ltd)
org.ident_country_code = 'EE'
org.save(validate: false)
org.reload
company_one = Company.new(org.ident, 'ace')
company_two = Company.new(org.ident, 'acer')
Spy.on(@user, :companies).and_return([company_one, company_two])
response = @user.do_need_update_contact?
org.reload
assert_equal response[:counter], 2
end
def test_returns_contacts
Contact.stub(:registrant_user_contacts, %w(john jane)) do
assert_equal %w(john jane), @user.contacts

View file

@ -29,4 +29,16 @@ class AdminAccountsSystemTest < ApplicationSystemTestCase
assert_text 'Account has been successfully updated'
assert_text '234'
end
def test_download_accounts_list_as_csv
travel_to Time.zone.parse('2010-07-05 10:30')
get admin_accounts_path(format: :csv)
assert_response :ok
assert_equal 'text/csv; charset=utf-8', response.headers['Content-Type']
assert_equal %(attachment; filename="accounts_#{Time.zone.now.to_formatted_s(:number)}.csv"; filename*=UTF-8''accounts_#{Time.zone.now.to_formatted_s(:number)}.csv),
response.headers['Content-Disposition']
assert_equal file_fixture('accounts.csv').read, response.body
end
end

View file

@ -62,11 +62,10 @@ class ContactVersionsTest < ApplicationSystemTestCase
travel_to now
get admin_contact_versions_path(format: :csv)
assert_response :ok
assert_equal 'text/csv; charset=utf-8', response.headers['Content-Type']
assert_equal %(attachment; filename="contact_history_#{Time.zone.now.to_formatted_s(:number)}.csv"; filename*=UTF-8''contact_history_#{Time.zone.now.to_formatted_s(:number)}.csv),
response.headers['Content-Disposition']
assert_not_empty response.body
assert_equal file_fixture('contact_versions.csv').read, response.body
end
end

View file

@ -0,0 +1,22 @@
require 'application_system_test_case'
class ContactsCsvTest < ApplicationSystemTestCase
setup do
sign_in users(:admin)
Domain.destroy_all
Contact.all.each { |contact| contact.destroy unless contact.name == 'Acme Ltd' }
end
def test_download_contacts_list_as_csv
travel_to Time.zone.parse('2010-07-05 10:30')
contact = Contact.first
contact.created_at = Time.zone.now
contact.save(validate: false)
visit admin_contacts_url
click_link('CSV')
assert_equal "attachment; filename=\"contacts_#{Time.zone.now.to_formatted_s(:number)}.csv\"; filename*=UTF-8''contacts_#{Time.zone.now.to_formatted_s(:number)}.csv", response_headers['Content-Disposition']
assert_equal file_fixture('contacts.csv').read, page.body
end
end

View file

@ -98,7 +98,7 @@ class DomainVersionsTest < ApplicationSystemTestCase
assert_equal 'text/csv; charset=utf-8', response.headers['Content-Type']
assert_equal %(attachment; filename="domain_history_#{Time.zone.now.to_formatted_s(:number)}.csv"; filename*=UTF-8''domain_history_#{Time.zone.now.to_formatted_s(:number)}.csv),
response.headers['Content-Disposition']
assert_not_empty response.body
assert_equal file_fixture('domain_versions.csv').read, response.body
end
def test_search_event_param

View file

@ -1,18 +1,21 @@
require 'application_system_test_case'
class AdminAreaCsvTest < ApplicationSystemTestCase
class DomainsCsvTest < ApplicationSystemTestCase
setup do
sign_in users(:admin)
Domain.all.each { |domain| domain.destroy unless domain.name == 'metro.test' }
end
def test_downloads_domain_list_as_csv
search_params = {"valid_to_lteq"=>nil}
expected_csv = Domain.includes(:registrar, :registrant).search(search_params).result.to_csv
def test_download_domains_list_as_csv
travel_to Time.zone.parse('2010-07-05 10:30')
domain = Domain.first
domain.created_at = Time.zone.now
domain.save(validate: false)
visit admin_domains_url
click_link('CSV')
assert_equal "attachment; filename=\"domains_#{Time.zone.now.to_formatted_s(:number)}.csv\"; filename*=UTF-8''domains_#{Time.zone.now.to_formatted_s(:number)}.csv", response_headers['Content-Disposition']
assert_equal expected_csv, page.body
assert_equal file_fixture('domains.csv').read, page.body
end
end

View file

@ -40,4 +40,14 @@ class AdminAreaInvoicesTest < ApplicationSystemTestCase
assert_current_path admin_invoice_path(@invoice)
assert_text 'Invoice has been sent'
end
def test_download_invoices_list_as_csv
travel_to Time.zone.parse('2010-07-05 10:30')
visit admin_invoices_url
click_link('CSV')
assert_equal "attachment; filename=\"invoices_#{Time.zone.now.to_formatted_s(:number)}.csv\"; filename*=UTF-8''invoices_#{Time.zone.now.to_formatted_s(:number)}.csv", response_headers['Content-Disposition']
assert_equal file_fixture('invoices.csv').read, page.body
end
end