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|
|
Registrar.all.each do |registrar|
|
||||||
next unless registrar.reference_no.start_with?('RF')
|
next unless registrar.reference_no.start_with?('RF')
|
||||||
|
|
||||||
registrar.reference_no = Billing::ReferenceNo.generate
|
registrar.update_columns(reference_no: Billing::ReferenceNo.generate)
|
||||||
registrar.save!
|
|
||||||
|
|
||||||
processed_registrar_count += 1
|
processed_registrar_count += 1
|
||||||
end
|
end
|
||||||
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
|
accounting_customer_code: any
|
||||||
language: en
|
language: en
|
||||||
reference_no: 39
|
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')
|
assert_not registrar.reference_no.start_with?('RF')
|
||||||
end
|
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
|
def test_does_not_regenerate_when_the_task_is_run_again
|
||||||
registrar = registrars(:bestnames)
|
registrar = registrars(:bestnames)
|
||||||
registrar.update!(reference_no: '1111')
|
registrar.update!(reference_no: '1111')
|
||||||
|
|
|
@ -5,10 +5,14 @@ class RegistrarTest < ActiveSupport::TestCase
|
||||||
@registrar = registrars(:bestnames)
|
@registrar = registrars(:bestnames)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_valid
|
def test_default_fixture_is_valid
|
||||||
assert @registrar.valid?, proc { @registrar.errors.full_messages }
|
assert @registrar.valid?, proc { @registrar.errors.full_messages }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_invalid_fixture_is_invalid
|
||||||
|
assert registrars(:invalid).invalid?
|
||||||
|
end
|
||||||
|
|
||||||
def test_invalid_without_name
|
def test_invalid_without_name
|
||||||
@registrar.name = ''
|
@registrar.name = ''
|
||||||
assert @registrar.invalid?
|
assert @registrar.invalid?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue