diff --git a/app/models/registrar.rb b/app/models/registrar.rb index de5b3a324a..fa8747114f 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -176,6 +176,11 @@ def e_invoice_iban iban end + def billing_email + return contact_email if self[:billing_email].blank? + self[:billing_email] + end + private def set_defaults diff --git a/test/models/registrar_test.rb b/test/models/registrar_test.rb index 7b3867f4a1..ae68ebeeae 100644 --- a/test/models/registrar_test.rb +++ b/test/models/registrar_test.rb @@ -63,6 +63,18 @@ def test_billing_email_format_validation assert registrar.valid? end + def test_returns_billing_email_when_provided + billing_email = 'billing@registrar.test' + registrar = Registrar.new(billing_email: billing_email) + assert_equal billing_email, registrar.billing_email + end + + def test_billing_email_fallback + contact_email = 'info@registrar.test' + registrar = Registrar.new(contact_email: contact_email, billing_email: '') + assert_equal contact_email, registrar.billing_email + end + def test_invalid_without_language registrar = valid_registrar registrar.language = ''