From 26fa15f76c7424e85a0c2da59320833fe3e66ff1 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 4 Jul 2019 17:17:03 +0300 Subject: [PATCH] Alias attribute --- app/models/registrar.rb | 2 ++ test/models/registrar_test.rb | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 030c2a824..de5b3a324 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -36,6 +36,8 @@ class Registrar < ActiveRecord::Base allow_blank: true, if: proc { |c| c.email_changed? } 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) after_commit :update_whois_records diff --git a/test/models/registrar_test.rb b/test/models/registrar_test.rb index 15c276018..7b3867f4a 100644 --- a/test/models/registrar_test.rb +++ b/test/models/registrar_test.rb @@ -145,6 +145,12 @@ class RegistrarTest < ActiveSupport::TestCase assert registrar.invalid? 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 registrar = Registrar.new(address_street: 'Main Street 1', address_zip: '1234', address_city: 'NY', address_state: 'NY State')