mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 18:56:05 +02:00
parent
fb35ec5cbb
commit
e1b0f3044e
2 changed files with 5 additions and 0 deletions
|
@ -160,6 +160,7 @@ class Invoice < ActiveRecord::Base
|
|||
|
||||
def total
|
||||
calculate_total unless total?
|
||||
read_attribute(:total)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -76,6 +76,10 @@ class InvoiceTest < ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_returns_persisted_total
|
||||
assert_equal BigDecimal('16.50'), @invoice.total
|
||||
end
|
||||
|
||||
def test_calculates_total
|
||||
line_item = InvoiceItem.new
|
||||
invoice = Invoice.new
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue