diff --git a/app/models/admin_user.rb b/app/models/admin_user.rb index 07686e921..159578ab0 100644 --- a/app/models/admin_user.rb +++ b/app/models/admin_user.rb @@ -4,7 +4,7 @@ class AdminUser < User validates :identity_code, presence: true, if: -> { country_code == 'EE' } validates :email, presence: true validates :password, :password_confirmation, presence: true, if: :new_record? - validates :password_confirmation, presence: true, if: :encrypted_password_changed? + validates :password_confirmation, presence: true, if: :will_save_change_to_encrypted_password? validate :validate_identity_code, if: -> { country_code == 'EE' } ROLES = %w(user customer_service admin) # should not match to api_users roles diff --git a/app/models/api_user.rb b/app/models/api_user.rb index e11dbf90f..3dc240727 100644 --- a/app/models/api_user.rb +++ b/app/models/api_user.rb @@ -43,7 +43,7 @@ class ApiUser < User after_initialize :set_defaults def set_defaults return unless new_record? - self.active = true unless active_changed? + self.active = true unless saved_change_to_active? end class << self diff --git a/app/models/contact.rb b/app/models/contact.rb index 31ef7241e..e4ed542a6 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -28,7 +28,7 @@ class Contact < ApplicationRecord validates :phone, presence: true, e164: true, phone: true validates :email, format: /@/ - validates :email, email_format: { message: :invalid }, if: proc { |c| c.email_changed? } + validates :email, email_format: { message: :invalid }, if: proc { |c| c.will_save_change_to_email? } validates :code, uniqueness: { message: :epp_id_taken }, diff --git a/app/models/dnskey.rb b/app/models/dnskey.rb index 922844874..08a5b03d8 100644 --- a/app/models/dnskey.rb +++ b/app/models/dnskey.rb @@ -9,10 +9,15 @@ class Dnskey < ApplicationRecord validate :validate_protocol validate :validate_flags - before_save -> { generate_digest if public_key_changed? && !ds_digest_changed? } + before_save -> { generate_digest if will_save_change_to_public_key? && + !will_save_change_to_ds_digest? } before_save lambda { - if (public_key_changed? || flags_changed? || alg_changed? || protocol_changed?) && !ds_key_tag_changed? + if (will_save_change_to_public_key? || + will_save_change_to_flags? || + will_save_change_to_alg? || + will_save_change_to_protocol?) && + !will_save_change_to_ds_key_tag? generate_ds_key_tag end } diff --git a/app/models/domain.rb b/app/models/domain.rb index d6545284d..3ad3b09f2 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -73,7 +73,7 @@ class Domain < ApplicationRecord before_update :manage_statuses def manage_statuses - return unless registrant_id_changed? # rollback has not yet happened + return unless will_save_change_to_registrant_id? # rollback has not yet happened pending_update! if registrant_verification_asked? true end @@ -547,7 +547,7 @@ class Domain < ApplicationRecord activate if nameservers.reject(&:marked_for_destruction?).size >= Setting.ns_min_count end - cancel_force_delete if force_delete_scheduled? && registrant_id_changed? + cancel_force_delete if force_delete_scheduled? && will_save_change_to_registrant_id? if statuses.empty? && valid? statuses << DomainStatus::OK diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index 742f0339f..fa488d9e1 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -182,7 +182,7 @@ class Epp::Contact < Contact self.attributes = at - email_changed = email_changed? + email_changed = will_save_change_to_email? old_email = email_was updated = save diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 3ebddf8ae..88aa1c629 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -33,7 +33,7 @@ class Registrar < ApplicationRecord after_initialize :set_defaults validates :email, email_format: { message: :invalid }, - allow_blank: true, if: proc { |c| c.email_changed? } + allow_blank: true, if: proc { |c| c.will_save_change_to_email? } validates :billing_email, email_format: { message: :invalid }, allow_blank: true alias_attribute :contact_email, :email