mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
Refactor registrars
- Reorganize views - Improve database structure - Use default translations - Combine tests
This commit is contained in:
parent
59e9b16dfa
commit
efb63399b2
27 changed files with 287 additions and 353 deletions
|
@ -15,7 +15,7 @@ class RegistrarVATTest < ActiveSupport::TestCase
|
|||
|
||||
def test_apply_vat_rate_from_registry_when_registrar_is_local_vat_payer
|
||||
Setting.registry_country_code = 'US'
|
||||
@registrar.country_code = 'US'
|
||||
@registrar.address_country_code = 'US'
|
||||
|
||||
Registry.instance.stub(:vat_rate, BigDecimal('5.5')) do
|
||||
assert_equal BigDecimal('5.5'), @registrar.effective_vat_rate
|
||||
|
@ -32,13 +32,13 @@ class RegistrarVATTest < ActiveSupport::TestCase
|
|||
|
||||
def test_apply_vat_rate_from_registrar_when_registrar_is_foreign_vat_payer
|
||||
Setting.registry_country_code = 'US'
|
||||
@registrar.country_code = 'DE'
|
||||
@registrar.address_country_code = 'DE'
|
||||
@registrar.vat_rate = BigDecimal('5.6')
|
||||
assert_equal BigDecimal('5.6'), @registrar.effective_vat_rate
|
||||
end
|
||||
|
||||
def test_require_vat_rate_when_registrar_is_foreign_vat_payer_and_vat_no_is_absent
|
||||
@registrar.country_code = 'DE'
|
||||
@registrar.address_country_code = 'DE'
|
||||
@registrar.vat_no = ''
|
||||
|
||||
@registrar.vat_rate = ''
|
||||
|
@ -50,7 +50,7 @@ class RegistrarVATTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_require_no_vat_rate_when_registrar_is_foreign_vat_payer_and_vat_no_is_present
|
||||
@registrar.country_code = 'DE'
|
||||
@registrar.address_country_code = 'DE'
|
||||
@registrar.vat_no = 'valid'
|
||||
|
||||
@registrar.vat_rate = 1
|
||||
|
@ -61,7 +61,7 @@ class RegistrarVATTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_vat_rate_validation
|
||||
@registrar.country_code = 'DE'
|
||||
@registrar.address_country_code = 'DE'
|
||||
@registrar.vat_no = ''
|
||||
|
||||
@registrar.vat_rate = -1
|
||||
|
@ -78,7 +78,7 @@ class RegistrarVATTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_serializes_and_deserializes_vat_rate
|
||||
@registrar.country_code = 'DE'
|
||||
@registrar.address_country_code = 'DE'
|
||||
@registrar.vat_rate = BigDecimal('25.5')
|
||||
@registrar.save!
|
||||
@registrar.reload
|
||||
|
|
|
@ -5,8 +5,8 @@ class RegistrarTest < ActiveSupport::TestCase
|
|||
@registrar = registrars(:bestnames)
|
||||
end
|
||||
|
||||
def test_default_fixture_is_valid
|
||||
assert @registrar.valid?, proc { @registrar.errors.full_messages }
|
||||
def test_valid_registrar_is_valid
|
||||
assert valid_registrar.valid?, proc { valid_registrar.errors.full_messages }
|
||||
end
|
||||
|
||||
def test_invalid_fixture_is_invalid
|
||||
|
@ -14,33 +14,33 @@ class RegistrarTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_invalid_without_name
|
||||
@registrar.name = ''
|
||||
assert @registrar.invalid?
|
||||
registrar = valid_registrar
|
||||
registrar.name = ''
|
||||
assert registrar.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_without_reg_no
|
||||
@registrar.reg_no = ''
|
||||
assert @registrar.invalid?
|
||||
registrar = valid_registrar
|
||||
registrar.reg_no = ''
|
||||
assert registrar.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_without_email
|
||||
@registrar.email = ''
|
||||
assert @registrar.invalid?
|
||||
registrar = valid_registrar
|
||||
registrar.email = ''
|
||||
assert registrar.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_without_accounting_customer_code
|
||||
@registrar.accounting_customer_code = ''
|
||||
assert @registrar.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_without_country_code
|
||||
@registrar.country_code = ''
|
||||
assert @registrar.invalid?
|
||||
registrar = valid_registrar
|
||||
registrar.accounting_customer_code = ''
|
||||
assert registrar.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_without_language
|
||||
@registrar.language = ''
|
||||
assert @registrar.invalid?
|
||||
registrar = valid_registrar
|
||||
registrar.language = ''
|
||||
assert registrar.invalid?
|
||||
end
|
||||
|
||||
def test_has_default_language
|
||||
|
@ -56,7 +56,9 @@ class RegistrarTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_full_address
|
||||
assert_equal 'Main Street, New York, New York, 12345', @registrar.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
|
||||
|
@ -96,4 +98,10 @@ class RegistrarTest < ActiveSupport::TestCase
|
|||
|
||||
Setting.days_to_keep_invoices_active = @original_days_to_keep_invoices_active_setting
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid_registrar
|
||||
registrars(:bestnames)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue