mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 20:18:22 +02:00
Validate registrar's billing email (#1253)
Previously it was being validated only if contact email changed (contact and billing emails have nothing in common).
This commit is contained in:
parent
1dfe30ccfd
commit
9bb73b7cdd
2 changed files with 19 additions and 3 deletions
|
@ -32,9 +32,9 @@ class Registrar < ActiveRecord::Base
|
||||||
attribute :vat_rate, ::Type::VATRate.new
|
attribute :vat_rate, ::Type::VATRate.new
|
||||||
after_initialize :set_defaults
|
after_initialize :set_defaults
|
||||||
|
|
||||||
validates :email, :billing_email,
|
validates :email, email_format: { message: :invalid },
|
||||||
email_format: { message: :invalid },
|
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
|
||||||
|
|
||||||
WHOIS_TRIGGERS = %w(name email phone street city state zip)
|
WHOIS_TRIGGERS = %w(name email phone street city state zip)
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,22 @@ class RegistrarTest < ActiveSupport::TestCase
|
||||||
assert registrar.invalid?
|
assert registrar.invalid?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_optional_billing_email
|
||||||
|
registrar = valid_registrar
|
||||||
|
registrar.billing_email = ''
|
||||||
|
assert registrar.valid?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_billing_email_format_validation
|
||||||
|
registrar = valid_registrar
|
||||||
|
|
||||||
|
registrar.billing_email = 'invalid'
|
||||||
|
assert registrar.invalid?
|
||||||
|
|
||||||
|
registrar.billing_email = 'valid@email.test'
|
||||||
|
assert registrar.valid?
|
||||||
|
end
|
||||||
|
|
||||||
def test_invalid_without_language
|
def test_invalid_without_language
|
||||||
registrar = valid_registrar
|
registrar = valid_registrar
|
||||||
registrar.language = ''
|
registrar.language = ''
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue