Skip to content

Commit

Permalink
Fall back on contact email if billing email is absent
Browse files Browse the repository at this point in the history
Affects e-invoice and invoice delivery form.

Fixes #1255
  • Loading branch information
Artur Beljajev authored and teadur committed Jul 8, 2019
1 parent 26fa15f commit 6356ce0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/models/registrar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions test/models/registrar_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ def test_billing_email_format_validation
assert registrar.valid?
end

def test_returns_billing_email_when_provided
billing_email = '[email protected]'
registrar = Registrar.new(billing_email: billing_email)
assert_equal billing_email, registrar.billing_email
end

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

0 comments on commit 6356ce0

Please sign in to comment.