mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 06:34:46 +02:00
parent
6f9ea85a95
commit
c47ca77ca6
9 changed files with 105 additions and 1 deletions
7
test/fixtures/registrars.yml
vendored
7
test/fixtures/registrars.yml
vendored
|
@ -16,3 +16,10 @@ goodnames:
|
|||
country_code: US
|
||||
accounting_customer_code: goodnames
|
||||
language: en
|
||||
|
||||
foreign_vat_payer_with_rate:
|
||||
<<: *DEFAULTS
|
||||
name: 3
|
||||
reg_no: 3
|
||||
code: 3
|
||||
vat_rate: 0.2
|
||||
|
|
|
@ -16,4 +16,12 @@ class ShowRegistrarTest < ActionDispatch::IntegrationTest
|
|||
def test_language
|
||||
assert_text 'Language English'
|
||||
end
|
||||
|
||||
def test_vat_number
|
||||
assert_text 'US12345'
|
||||
end
|
||||
|
||||
def test_vat_rate
|
||||
assert_text number_to_percentage(@registrar.vat_rate, precision: 1)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,4 +38,54 @@ class RegistrarTest < ActiveSupport::TestCase
|
|||
registrar = Registrar.new(language: 'de')
|
||||
assert_equal 'de', registrar.language
|
||||
end
|
||||
|
||||
def test_rejects_vat_number_when_local_vat_payer
|
||||
Registry.instance.stub(:legal_address_country, Country.new('US')) do
|
||||
@registrar.vat_no = 'US1'
|
||||
@registrar.validate
|
||||
assert @registrar.invalid?
|
||||
end
|
||||
end
|
||||
|
||||
def test_rejects_vat_rate_when_local_vat_payer
|
||||
Registry.instance.stub(:legal_address_country, Country.new('US')) do
|
||||
@registrar.vat_rate = 20
|
||||
@registrar.validate
|
||||
assert @registrar.invalid?
|
||||
end
|
||||
end
|
||||
|
||||
def test_rejects_negative_vat_rate
|
||||
@registrar.vat_rate = -1
|
||||
@registrar.validate
|
||||
assert @registrar.invalid?
|
||||
end
|
||||
|
||||
def test_rejects_vat_rate_greater_than_max
|
||||
@registrar.vat_rate = 100
|
||||
@registrar.validate
|
||||
assert @registrar.invalid?
|
||||
end
|
||||
|
||||
def test_converts_integer_vat_rate_to_fractional
|
||||
@registrar = registrars(:foreign_vat_payer_with_rate)
|
||||
assert_equal 20, @registrar.vat_rate
|
||||
end
|
||||
|
||||
def test_requires_vat_rate_when_foreign_vat_payer_without_number
|
||||
Registry.instance.stub(:legal_address_country, Country.new('GB')) do
|
||||
@registrar.vat_no = nil
|
||||
@registrar.validate
|
||||
assert @registrar.invalid?
|
||||
end
|
||||
end
|
||||
|
||||
def test_rejects_vat_rate_when_foreign_vat_payer_with_number
|
||||
Registry.instance.stub(:legal_address_country, Country.new('GB')) do
|
||||
@registrar.vat_no = 'US1'
|
||||
@registrar.vat_rate = 1
|
||||
@registrar.validate
|
||||
assert @registrar.invalid?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,8 @@ require 'webmock/minitest'
|
|||
|
||||
Setting.address_processing = false
|
||||
|
||||
Setting.registry_country_code = 'US'
|
||||
|
||||
class ActiveSupport::TestCase
|
||||
include FactoryBot::Syntax::Methods
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue