mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 00:12:03 +02:00
Remove unused code
This commit is contained in:
parent
11e4329c70
commit
9dffe962b6
3 changed files with 0 additions and 62 deletions
4
.reek
4
.reek
|
@ -114,7 +114,6 @@ UncommunicativeVariableName:
|
|||
- Invoice#cancel_overdue_invoices
|
||||
- Legacy::Db
|
||||
- LegalDocument#save_to_filesystem
|
||||
- Nameserver#replace_hostname_ends
|
||||
- RegistrantUser#find_or_create_by_idc_data
|
||||
- RegistrantUser#find_or_create_by_mid_data
|
||||
- Registrar
|
||||
|
@ -327,7 +326,6 @@ DuplicateMethodCall:
|
|||
- Invoice#set_invoice_number
|
||||
- LegalDocument#save_to_filesystem
|
||||
- LegalDocument#self.remove_duplicates
|
||||
- Nameserver#replace_hostname_ends
|
||||
- Setting#self.params_errors
|
||||
- Setting#self.reload_settings!
|
||||
- Soap::Arireg#associated_businesses
|
||||
|
@ -822,7 +820,6 @@ TooManyStatements:
|
|||
- Invoice#set_invoice_number
|
||||
- LegalDocument#save_to_filesystem
|
||||
- LegalDocument#self.remove_duplicates
|
||||
- Nameserver#replace_hostname_ends
|
||||
- RegistrantUser#find_or_create_by_idc_data
|
||||
- Registrar#generate_iso_11649_reference_no
|
||||
- Soap::Arireg#associated_businesses
|
||||
|
@ -1026,7 +1023,6 @@ NestedIterators:
|
|||
- Domain#self.to_csv
|
||||
- Epp::Domain#nameservers_from
|
||||
- LegalDocument#self.remove_duplicates
|
||||
- Nameserver#replace_hostname_ends
|
||||
- RegistrantPresenter#domain_names_with_roles
|
||||
- UniquenessMultiValidator#validate_each
|
||||
UnusedParameters:
|
||||
|
|
|
@ -73,37 +73,6 @@ class Nameserver < ActiveRecord::Base
|
|||
end
|
||||
|
||||
class << self
|
||||
def replace_hostname_ends(domains, old_end, new_end)
|
||||
domains = domains.where('EXISTS(
|
||||
select 1 from nameservers ns where ns.domain_id = domains.id AND ns.hostname LIKE ?
|
||||
)', "%#{old_end}")
|
||||
|
||||
count, success_count = 0.0, 0.0
|
||||
domains.each do |d|
|
||||
ns_attrs = { nameservers_attributes: [] }
|
||||
|
||||
d.nameservers.each do |ns|
|
||||
next unless ns.hostname.end_with?(old_end)
|
||||
|
||||
hn = ns.hostname.chomp(old_end)
|
||||
ns_attrs[:nameservers_attributes] << {
|
||||
id: ns.id,
|
||||
hostname: "#{hn}#{new_end}"
|
||||
}
|
||||
end
|
||||
|
||||
success_count += 1 if d.update(ns_attrs)
|
||||
count += 1
|
||||
end
|
||||
|
||||
return 'replaced_none' if count == 0.0
|
||||
|
||||
prc = success_count / count
|
||||
|
||||
return 'replaced_all' if prc == 1.0
|
||||
'replaced_some'
|
||||
end
|
||||
|
||||
def find_by_hash_params params
|
||||
params = params.with_indifferent_access
|
||||
rel = all
|
||||
|
|
|
@ -81,33 +81,6 @@ describe Nameserver do
|
|||
create(:nameserver, hostname: 'ns3.test.ee')
|
||||
])
|
||||
end
|
||||
|
||||
it 'should replace hostname ends' do
|
||||
res = Nameserver.replace_hostname_ends(@api_user.registrar.domains, 'ns.ee', 'test.ee')
|
||||
res.should == 'replaced_some'
|
||||
|
||||
@api_user.registrar.nameservers.where("hostname LIKE '%test.ee'").count.should == 4
|
||||
@domain_1.nameservers.pluck(:hostname).should include('ns1.ns.ee', 'ns2.ns.ee', 'ns2.test.ee')
|
||||
@domain_2.nameservers.pluck(:hostname).should include('ns1.test.ee', 'ns2.test.ee', 'ns3.test.ee')
|
||||
|
||||
res = Nameserver.replace_hostname_ends(@api_user.registrar.domains, 'test.ee', 'testing.ee')
|
||||
res.should == 'replaced_all'
|
||||
|
||||
@api_user.registrar.nameservers.where("hostname LIKE '%testing.ee'").count.should == 4
|
||||
@domain_1.nameservers.pluck(:hostname).should include('ns1.ns.ee', 'ns2.ns.ee', 'ns2.testing.ee')
|
||||
@domain_2.nameservers.pluck(:hostname).should include('ns1.testing.ee', 'ns2.testing.ee', 'ns3.testing.ee')
|
||||
|
||||
res = Nameserver.replace_hostname_ends(@api_user.registrar.domains, 'ns.ee', 'test.ee')
|
||||
res.should == 'replaced_all'
|
||||
|
||||
@api_user.registrar.nameservers.where("hostname LIKE '%test.ee'").count.should == 2
|
||||
@domain_1.nameservers.pluck(:hostname).should include('ns1.test.ee', 'ns2.test.ee', 'ns2.testing.ee')
|
||||
@domain_2.nameservers.pluck(:hostname).should include('ns1.testing.ee', 'ns2.testing.ee', 'ns3.testing.ee')
|
||||
@domain_3.nameservers.pluck(:hostname).should include('ns1.ns.ee', 'ns2.ns.ee', 'ns3.test.ee')
|
||||
|
||||
res = Nameserver.replace_hostname_ends(@api_user.registrar.domains, 'xcv.ee', 'test.ee')
|
||||
res.should == 'replaced_none'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue