Improve readability

#746
This commit is contained in:
Artur Beljajev 2018-03-06 13:11:22 +02:00
parent 5319243e09
commit 046b9e96ce
6 changed files with 13 additions and 13 deletions

View file

@ -203,7 +203,7 @@ class Contact < ActiveRecord::Base
ver_scope << "(children->'#{type}')::jsonb <@ json_build_array(#{contact.id})::jsonb" ver_scope << "(children->'#{type}')::jsonb <@ json_build_array(#{contact.id})::jsonb"
end end
next if DomainVersion.where("created_at > ?", Time.now - Setting.orphans_contacts_in_months.to_i.months).where(ver_scope.join(" OR ")).any? next if DomainVersion.where("created_at > ?", Time.now - Setting.orphans_contacts_in_months.to_i.months).where(ver_scope.join(" OR ")).any?
next if contact.used? next if contact.in_use?
contact.destroy contact.destroy
counter.next counter.next
@ -276,7 +276,7 @@ class Contact < ActiveRecord::Base
calculated.delete(Contact::OK) calculated.delete(Contact::OK)
calculated.delete(Contact::LINKED) calculated.delete(Contact::LINKED)
calculated << Contact::OK if calculated.empty?# && valid? calculated << Contact::OK if calculated.empty?# && valid?
calculated << Contact::LINKED if used? calculated << Contact::LINKED if in_use?
calculated.uniq calculated.uniq
end end
@ -344,7 +344,7 @@ class Contact < ActiveRecord::Base
# no need separate method # no need separate method
# should use only in transaction # should use only in transaction
def destroy_and_clean frame def destroy_and_clean frame
if used? if in_use?
errors.add(:domains, :exist) errors.add(:domains, :exist)
return false return false
end end
@ -540,7 +540,7 @@ class Contact < ActiveRecord::Base
Country.new(ident_country_code) Country.new(ident_country_code)
end end
def used? def in_use?
registrant_domains.any? || domain_contacts.any? registrant_domains.any? || domain_contacts.any?
end end

View file

@ -8,7 +8,7 @@ class RegistrantPresenter
:reg_no, :reg_no,
:street, :city, :state, :zip, :country, :street, :city, :state, :zip, :country,
:ident_country, :ident_country,
:used?, :in_use?,
to: :registrant to: :registrant
def initialize(registrant:, view:) def initialize(registrant:, view:)

View file

@ -10,7 +10,7 @@ uus aadress: <%= contact.email %>
<br><br> <br><br>
E-posti aadressile saadetakse domeeni toimingutega seotud infot, sealhulgas kinnitustaotlused omanikuvahetuse ja domeeni kustutamise korral. E-posti aadressile saadetakse domeeni toimingutega seotud infot, sealhulgas kinnitustaotlused omanikuvahetuse ja domeeni kustutamise korral.
<br><br> <br><br>
<% if contact.used? %> <% if contact.in_use? %>
Muudatusega seotud domeenid:<br> Muudatusega seotud domeenid:<br>
<%= contact.domain_names_with_roles(locale: :et, line_break: '<br>') %> <%= contact.domain_names_with_roles(locale: :et, line_break: '<br>') %>
<% end %> <% end %>
@ -34,7 +34,7 @@ new address: <%= contact.email %>
<br><br> <br><br>
E-mail addresses are used to send important information regarding your registered domains including applications for approval of registrant change and domain deletion. Please make sure that the update and contact information are correct. E-mail addresses are used to send important information regarding your registered domains including applications for approval of registrant change and domain deletion. Please make sure that the update and contact information are correct.
<br><br> <br><br>
<% if contact.used? %> <% if contact.in_use? %>
Domains affected by this update:<br> Domains affected by this update:<br>
<%= contact.domain_names_with_roles(line_break: '<br>') %> <%= contact.domain_names_with_roles(line_break: '<br>') %>
<% end %> <% end %>

View file

@ -10,7 +10,7 @@ uus aadress: <%= contact.email %>
E-posti aadressile saadetakse domeeni toimingutega seotud infot, sealhulgas kinnitustaotlused omanikuvahetuse ja domeeni kustutamise korral. E-posti aadressile saadetakse domeeni toimingutega seotud infot, sealhulgas kinnitustaotlused omanikuvahetuse ja domeeni kustutamise korral.
<% if contact.used? %> <% if contact.in_use? %>
Muudatusega seotud domeenid: Muudatusega seotud domeenid:
<%= contact.domain_names_with_roles(locale: :et) %> <%= contact.domain_names_with_roles(locale: :et) %>
<% end %> <% end %>
@ -34,7 +34,7 @@ new address: <%= contact.email %>
E-mail addresses are used to send important information regarding your registered domains including applications for approval of registrant change and domain deletion. Please make sure that the update and contact information are correct. E-mail addresses are used to send important information regarding your registered domains including applications for approval of registrant change and domain deletion. Please make sure that the update and contact information are correct.
<% if contact.used? %> <% if contact.in_use? %>
Domains affected by this update: Domains affected by this update:
<%= contact.domain_names_with_roles %> <%= contact.domain_names_with_roles %>
<% end %> <% end %>

View file

@ -67,7 +67,7 @@ RSpec.describe RegistrantPresenter do
zip zip
id_code id_code
reg_no reg_no
used? in_use?
) )
registrant_delegatable_attributes.each do |attr_name| registrant_delegatable_attributes.each do |attr_name|

View file

@ -15,15 +15,15 @@ class ContactTest < ActiveSupport::TestCase
def test_in_use_if_acts_as_a_registrant def test_in_use_if_acts_as_a_registrant
DomainContact.delete_all DomainContact.delete_all
assert @contact.used? assert @contact.in_use?
end end
def test_in_use_if_acts_as_a_domain_contact def test_in_use_if_acts_as_a_domain_contact
Domain.update_all(registrant_id: contacts(:william)) Domain.update_all(registrant_id: contacts(:william))
assert @contact.used? assert @contact.in_use?
end end
def test_not_in_use_if_acts_as_neither_registrant_nor_domain_contact def test_not_in_use_if_acts_as_neither_registrant_nor_domain_contact
refute contacts(:not_in_use).used? refute contacts(:not_in_use).in_use?
end end
end end