Alias attribute

This commit is contained in:
Artur Beljajev 2019-07-04 17:17:03 +03:00 committed by Georg
parent bff2d88036
commit 26fa15f76c
2 changed files with 8 additions and 0 deletions

View file

@ -36,6 +36,8 @@ class Registrar < ActiveRecord::Base
allow_blank: true, if: proc { |c| c.email_changed? } allow_blank: true, if: proc { |c| c.email_changed? }
validates :billing_email, email_format: { message: :invalid }, allow_blank: true validates :billing_email, email_format: { message: :invalid }, allow_blank: true
alias_attribute :contact_email, :email
WHOIS_TRIGGERS = %w(name email phone street city state zip) WHOIS_TRIGGERS = %w(name email phone street city state zip)
after_commit :update_whois_records after_commit :update_whois_records

View file

@ -145,6 +145,12 @@ class RegistrarTest < ActiveSupport::TestCase
assert registrar.invalid? assert registrar.invalid?
end end
def test_aliases_contact_email_to_email
email = 'info@registrar.test'
registrar = Registrar.new(email: email)
assert_equal email, registrar.contact_email
end
def test_full_address def test_full_address
registrar = Registrar.new(address_street: 'Main Street 1', address_zip: '1234', registrar = Registrar.new(address_street: 'Main Street 1', address_zip: '1234',
address_city: 'NY', address_state: 'NY State') address_city: 'NY', address_state: 'NY State')