mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 13:44:47 +02:00
Merge pull request #1046 from internetee/change-reference-number-algo
Change reference number algo
This commit is contained in:
commit
2bcd79d5d9
4 changed files with 28 additions and 4 deletions
|
@ -6,9 +6,7 @@ namespace :data_migrations do
|
|||
Registrar.all.each do |registrar|
|
||||
next unless registrar.reference_no.start_with?('RF')
|
||||
|
||||
registrar.reference_no = Billing::ReferenceNo.generate
|
||||
registrar.save!
|
||||
|
||||
registrar.update_columns(reference_no: Billing::ReferenceNo.generate)
|
||||
processed_registrar_count += 1
|
||||
end
|
||||
end
|
||||
|
|
11
test/fixtures/registrars.yml
vendored
11
test/fixtures/registrars.yml
vendored
|
@ -35,3 +35,14 @@ not_in_use:
|
|||
accounting_customer_code: any
|
||||
language: en
|
||||
reference_no: 39
|
||||
|
||||
invalid:
|
||||
name: ""
|
||||
reg_no: any
|
||||
code: another
|
||||
email: any
|
||||
country_code: US
|
||||
vat_no: any
|
||||
accounting_customer_code: any
|
||||
language: en
|
||||
reference_no: 42
|
||||
|
|
|
@ -11,6 +11,17 @@ class RegenerateRegistrarReferenceNumbersTaskTest < ActiveSupport::TestCase
|
|||
assert_not registrar.reference_no.start_with?('RF')
|
||||
end
|
||||
|
||||
def test_bypasses_registrar_validation
|
||||
registrar = registrars(:invalid)
|
||||
registrar.update_column(:reference_no, 'RF1111')
|
||||
assert registrar.invalid?
|
||||
|
||||
capture_io { run_task }
|
||||
registrar.reload
|
||||
|
||||
assert_not registrar.reference_no.start_with?('RF')
|
||||
end
|
||||
|
||||
def test_does_not_regenerate_when_the_task_is_run_again
|
||||
registrar = registrars(:bestnames)
|
||||
registrar.update!(reference_no: '1111')
|
||||
|
|
|
@ -5,10 +5,14 @@ class RegistrarTest < ActiveSupport::TestCase
|
|||
@registrar = registrars(:bestnames)
|
||||
end
|
||||
|
||||
def test_valid
|
||||
def test_default_fixture_is_valid
|
||||
assert @registrar.valid?, proc { @registrar.errors.full_messages }
|
||||
end
|
||||
|
||||
def test_invalid_fixture_is_invalid
|
||||
assert registrars(:invalid).invalid?
|
||||
end
|
||||
|
||||
def test_invalid_without_name
|
||||
@registrar.name = ''
|
||||
assert @registrar.invalid?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue