mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 06:34:46 +02:00
Add more tests to deposit handling
This commit is contained in:
parent
b8c082090e
commit
c028c0e477
3 changed files with 32 additions and 3 deletions
|
@ -29,7 +29,7 @@ class Deposit
|
|||
|
||||
def amount
|
||||
return BigDecimal('0.0') if @amount.blank?
|
||||
BigDecimal(@amount, 10)
|
||||
BigDecimal(@amount.to_s.gsub(/,/, '.'), 10)
|
||||
end
|
||||
|
||||
def issue_prepayment_invoice
|
||||
|
|
|
@ -40,8 +40,8 @@ class DepositTest < ActiveSupport::TestCase
|
|||
@deposit.amount = "12.00"
|
||||
assert_equal(BigDecimal.new("12.00"), @deposit.amount)
|
||||
|
||||
@deposit.amount = "12,00"
|
||||
assert_equal(BigDecimal.new("12.00"), @deposit.amount)
|
||||
@deposit.amount = "12,11"
|
||||
assert_equal(BigDecimal.new("12.11"), @deposit.amount)
|
||||
end
|
||||
|
||||
def test_amount_is_converted_from_float
|
||||
|
|
|
@ -29,6 +29,22 @@ class NewInvoiceTest < ApplicationSystemTestCase
|
|||
assert_text 'Pay invoice'
|
||||
end
|
||||
|
||||
def test_create_new_invoice_with_comma_in_number
|
||||
visit registrar_invoices_path
|
||||
click_link_or_button 'Add deposit'
|
||||
fill_in 'Amount', with: '200,00'
|
||||
fill_in 'Description', with: 'My first invoice'
|
||||
|
||||
assert_difference 'Invoice.count', 1 do
|
||||
click_link_or_button 'Add'
|
||||
end
|
||||
|
||||
assert_text 'Please pay the following invoice'
|
||||
assert_text 'Invoice no. 131050'
|
||||
assert_text 'Subtotal 200,00 €'
|
||||
assert_text 'Pay invoice'
|
||||
end
|
||||
|
||||
def test_create_new_invoice_fails_when_amount_is_0
|
||||
visit registrar_invoices_path
|
||||
click_link_or_button 'Add deposit'
|
||||
|
@ -41,4 +57,17 @@ class NewInvoiceTest < ApplicationSystemTestCase
|
|||
|
||||
assert_text 'Amount is too small. Minimum deposit is 0.01 EUR'
|
||||
end
|
||||
|
||||
def test_create_new_invoice_fails_when_amount_is_negative
|
||||
visit registrar_invoices_path
|
||||
click_link_or_button 'Add deposit'
|
||||
fill_in 'Amount', with: '-120.00'
|
||||
fill_in 'Description', with: 'My first invoice'
|
||||
|
||||
assert_no_difference 'Invoice.count' do
|
||||
click_link_or_button 'Add'
|
||||
end
|
||||
|
||||
assert_text 'Amount is too small. Minimum deposit is 0.01 EUR'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue