mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 19:20:37 +02:00
parent
efb63399b2
commit
04575295ee
7 changed files with 68 additions and 26 deletions
12
test/fixtures/registrars.yml
vendored
12
test/fixtures/registrars.yml
vendored
|
@ -19,6 +19,10 @@ goodnames:
|
|||
reg_no: 12345
|
||||
code: goodnames
|
||||
email: info@goodnames.test
|
||||
address_street: Main Street 1
|
||||
address_zip: 1234
|
||||
address_city: NY
|
||||
address_state: NY State
|
||||
address_country_code: US
|
||||
vat_no: DE123456789
|
||||
accounting_customer_code: goodnames
|
||||
|
@ -30,6 +34,10 @@ not_in_use:
|
|||
reg_no: any
|
||||
code: any
|
||||
email: any@example.com
|
||||
address_street: Main Street 1
|
||||
address_zip: 1234
|
||||
address_city: NY
|
||||
address_state: NY State
|
||||
address_country_code: US
|
||||
vat_no: any
|
||||
accounting_customer_code: any
|
||||
|
@ -41,6 +49,10 @@ invalid:
|
|||
reg_no: any
|
||||
code: another
|
||||
email: any
|
||||
address_street: Main Street 1
|
||||
address_zip: 1234
|
||||
address_city: NY
|
||||
address_state: NY State
|
||||
address_country_code: US
|
||||
vat_no: any
|
||||
accounting_customer_code: any
|
||||
|
|
|
@ -55,12 +55,6 @@ class RegistrarTest < ActiveSupport::TestCase
|
|||
assert_equal 'de', registrar.language
|
||||
end
|
||||
|
||||
def test_full_address
|
||||
registrar = Registrar.new(address_street: 'Main Street 1', address_zip: '1234',
|
||||
address_city: 'NY', address_state: 'NY State')
|
||||
assert_equal 'Main Street 1, NY, NY State, 1234', registrar.address
|
||||
end
|
||||
|
||||
def test_validates_reference_number_format
|
||||
@registrar.reference_no = '1'
|
||||
assert @registrar.invalid?
|
||||
|
@ -99,6 +93,24 @@ class RegistrarTest < ActiveSupport::TestCase
|
|||
Setting.days_to_keep_invoices_active = @original_days_to_keep_invoices_active_setting
|
||||
end
|
||||
|
||||
def test_invalid_without_address
|
||||
registrar = valid_registrar
|
||||
address_parts = %i[street zip city state country_code]
|
||||
|
||||
address_parts.each do |address_part|
|
||||
attribute_name = "address_#{address_part}"
|
||||
registrar.public_send("#{attribute_name}=", '')
|
||||
assert registrar.invalid?, "#{attribute_name} should be required"
|
||||
registrar.public_send("#{attribute_name}=", 'some')
|
||||
end
|
||||
end
|
||||
|
||||
def test_full_address
|
||||
registrar = Registrar.new(address_street: 'Main Street 1', address_zip: '1234',
|
||||
address_city: 'NY', address_state: 'NY State')
|
||||
assert_equal 'Main Street 1, NY, NY State, 1234', registrar.address
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid_registrar
|
||||
|
|
|
@ -9,21 +9,25 @@ class AdminRegistrarsSystemTest < ApplicationSystemTestCase
|
|||
end
|
||||
|
||||
def test_creates_new_registrar
|
||||
assert_nil Registrar.find_by(name: 'New name')
|
||||
assert_nil Registrar.find_by(name: 'Acme Ltd')
|
||||
|
||||
visit admin_registrars_path
|
||||
click_on 'New registrar'
|
||||
|
||||
fill_in 'Name', with: 'New name'
|
||||
fill_in 'Reg no', with: '55555555'
|
||||
fill_in 'Contact e-mail', with: 'any@registrar.test'
|
||||
fill_in 'Name', with: 'Acme Ltd'
|
||||
fill_in 'Reg no', with: '1234'
|
||||
fill_in 'Contact e-mail', with: 'any@acme.test'
|
||||
fill_in 'Street', with: 'any'
|
||||
fill_in 'City', with: 'any'
|
||||
fill_in 'State / Province', with: 'any'
|
||||
fill_in 'Zip', with: 'any'
|
||||
select 'United States', from: 'Country'
|
||||
fill_in 'Accounting customer code', with: 'test'
|
||||
fill_in 'Code', with: 'test'
|
||||
click_on 'Create registrar'
|
||||
|
||||
assert_text 'Registrar has been successfully created'
|
||||
assert_text 'New name'
|
||||
assert_text 'Acme Ltd'
|
||||
end
|
||||
|
||||
def test_updates_registrar
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue