mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 01:11:43 +02:00
Merge branch 'registry-765' into registry-623
# Conflicts: # app/models/registrar.rb # config/locales/en.yml # spec/models/registrar_spec.rb # test/models/registrar_test.rb
This commit is contained in:
commit
4f51f6c736
35 changed files with 464 additions and 482 deletions
|
@ -9,9 +9,23 @@ class RegistrarTest < ActiveSupport::TestCase
|
|||
assert @registrar.valid?
|
||||
end
|
||||
|
||||
def test_invalid_without_name
|
||||
@registrar.name = ''
|
||||
assert @registrar.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_without_reg_no
|
||||
@registrar.reg_no = ''
|
||||
assert @registrar.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_without_email
|
||||
@registrar.email = ''
|
||||
assert @registrar.invalid?
|
||||
end
|
||||
|
||||
def test_rejects_absent_accounting_customer_code
|
||||
@registrar.accounting_customer_code = nil
|
||||
@registrar.validate
|
||||
assert @registrar.invalid?
|
||||
end
|
||||
|
||||
|
@ -20,9 +34,8 @@ class RegistrarTest < ActiveSupport::TestCase
|
|||
assert @registrar.invalid?
|
||||
end
|
||||
|
||||
def test_requires_language
|
||||
@registrar.language = nil
|
||||
@registrar.validate
|
||||
def test_invalid_without_language
|
||||
@registrar.language = ''
|
||||
assert @registrar.invalid?
|
||||
end
|
||||
|
||||
|
@ -38,65 +51,12 @@ class RegistrarTest < ActiveSupport::TestCase
|
|||
assert_equal 'de', registrar.language
|
||||
end
|
||||
|
||||
def test_rejects_vat_no_when_local_vat_payer
|
||||
Registry.instance.stub(:legal_address_country, Country.new('US')) do
|
||||
@registrar.vat_no = 'US1'
|
||||
@registrar.validate
|
||||
assert @registrar.invalid?
|
||||
end
|
||||
def test_full_address
|
||||
assert_equal 'Main Street, New York, New York, 12345', @registrar.address
|
||||
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
|
||||
def test_reference_number_generation
|
||||
@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_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
|
||||
|
||||
def test_serializes_and_deserializes_vat_rate
|
||||
valid_attributes = registrars(:bestnames).attributes.except('id').merge({ name: 'uniq1',
|
||||
reg_no: 'uniq1',
|
||||
code: 'uniq1',
|
||||
country_code: 'GB' })
|
||||
registrar = Registrar.new(valid_attributes)
|
||||
registrar.vat_rate = 55
|
||||
registrar.save!
|
||||
registrar.reload
|
||||
assert_equal 55, registrar.vat_rate
|
||||
end
|
||||
|
||||
def test_treats_empty_vat_rate_as_absent
|
||||
@registrar.vat_rate = ''
|
||||
assert_nil @registrar.vat_rate
|
||||
refute_empty @registrar.reference_no
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue