Skip to content

Commit

Permalink
Alias attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Beljajev authored and teadur committed Jul 8, 2019
1 parent bff2d88 commit 26fa15f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/registrar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions test/models/registrar_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ def test_invalid_without_address_country_code
assert registrar.invalid?
end

def test_aliases_contact_email_to_email
email = '[email protected]'
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')
Expand Down

0 comments on commit 26fa15f

Please sign in to comment.