mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 17:37:17 +02:00
Added registrar legacy migration and don't allow blank nor colon in code
This commit is contained in:
parent
834d638423
commit
8f23ef510d
4 changed files with 89 additions and 2 deletions
|
@ -138,6 +138,6 @@ class Registrar < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def code=(code)
|
def code=(code)
|
||||||
self[:code] = code.upcase if new_record? && code.present?
|
self[:code] = code.gsub(/[ :]/, '').upcase if new_record? && code.present?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
63
db/migrate/20150504104922_add_legacy_registrar_code.rb
Normal file
63
db/migrate/20150504104922_add_legacy_registrar_code.rb
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
class AddLegacyRegistrarCode < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
legacy_codes = [
|
||||||
|
[1, "EEDIRECT"],
|
||||||
|
[2, "ALMIC"],
|
||||||
|
[3, "ELION"],
|
||||||
|
[4, "SPINTEK"],
|
||||||
|
[5, "LINXTELECOM"],
|
||||||
|
[6, "ZONE"],
|
||||||
|
[7, "WEBNEST"],
|
||||||
|
[8, "NETPOINT"],
|
||||||
|
[9, "EESTIDOMEENID"],
|
||||||
|
[10, "CEMTY"],
|
||||||
|
[11, "NORTHSIDE"],
|
||||||
|
[12, "EENET"],
|
||||||
|
[13, "ELKDATA"],
|
||||||
|
[14, "ELISA"],
|
||||||
|
[15, "OKIA"],
|
||||||
|
[16, "NAMEISP"],
|
||||||
|
[17, "ASCIO"],
|
||||||
|
[18, "TPT"],
|
||||||
|
[22, "TPT2"],
|
||||||
|
[23, "INFONET"],
|
||||||
|
[24, "INTERFRAME"],
|
||||||
|
[25, "DOMAININFO"],
|
||||||
|
[26, "DELETEDDOMAINS"],
|
||||||
|
[27, "WAVECOM"],
|
||||||
|
[28, "CACTUSHOSTING"],
|
||||||
|
[29, "IPMIRROR"],
|
||||||
|
[30, "ALFANET"],
|
||||||
|
[31, "RIKS"],
|
||||||
|
[32, "AKS"],
|
||||||
|
[33, "VIRTUAAL"],
|
||||||
|
[34, "MIKARE_BALTIC"],
|
||||||
|
[35, "COMPIC"],
|
||||||
|
[36, "NETIM"],
|
||||||
|
[37, "TRENET"],
|
||||||
|
[38, "INSTRA"],
|
||||||
|
[39, "123DOMAIN.EU"],
|
||||||
|
[40, "EDICY"],
|
||||||
|
[41, "MAJANDUSTARKVARA"],
|
||||||
|
[44, "SAFENAMES"],
|
||||||
|
[45, "INFOWEB"],
|
||||||
|
[46, "EURODNS"],
|
||||||
|
[47, "INNTER.NET"],
|
||||||
|
[48, "RADICENTER"],
|
||||||
|
[49, "DBWEB"],
|
||||||
|
[50, "NAMESHIELD"],
|
||||||
|
[51, "CEMTY_OU"],
|
||||||
|
[52, "INFOBIT"]
|
||||||
|
]
|
||||||
|
|
||||||
|
legacy_codes.each do |lc|
|
||||||
|
legacy_id = lc.first
|
||||||
|
legacy_code = lc.second
|
||||||
|
registrar = Registrar.find_by(legacy_id: legacy_id)
|
||||||
|
next if registrar.blank?
|
||||||
|
old_code = registrar.code
|
||||||
|
registrar.update_column(:code, legacy_code)
|
||||||
|
puts "Registrar code updated: #{registrar.id}; #{registrar.name}; old: #{old_code}; new: #{registrar.reload.code}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20150430121807) do
|
ActiveRecord::Schema.define(version: 20150504104922) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
|
|
@ -65,6 +65,30 @@ describe Registrar do
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should remove blank from code' do
|
||||||
|
registrar = Fabricate.build(:registrar, code: 'with blank')
|
||||||
|
registrar.valid?
|
||||||
|
registrar.errors.full_messages.should match_array([
|
||||||
|
])
|
||||||
|
registrar.code.should == 'WITHBLANK'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should remove colon from code' do
|
||||||
|
registrar = Fabricate.build(:registrar, code: 'with colon:and:blank')
|
||||||
|
registrar.valid?
|
||||||
|
registrar.errors.full_messages.should match_array([
|
||||||
|
])
|
||||||
|
registrar.code.should == 'WITHCOLONANDBLANK'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should allow dot in code' do
|
||||||
|
registrar = Fabricate.build(:registrar, code: 'with.dot')
|
||||||
|
registrar.valid?
|
||||||
|
registrar.errors.full_messages.should match_array([
|
||||||
|
])
|
||||||
|
registrar.code.should == 'WITH.DOT'
|
||||||
|
end
|
||||||
|
|
||||||
it 'should have one version' do
|
it 'should have one version' do
|
||||||
with_versioning do
|
with_versioning do
|
||||||
@registrar.versions.should == []
|
@registrar.versions.should == []
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue