mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
Merge branch 'master' into update-ruby-to-2-4
This commit is contained in:
commit
0962ea3fd0
5 changed files with 102 additions and 51 deletions
59
test/models/deposit_test.rb
Normal file
59
test/models/deposit_test.rb
Normal file
|
@ -0,0 +1,59 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DepositTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
super
|
||||
|
||||
@deposit = Deposit.new(registrar: registrars(:bestnames))
|
||||
@minimum_deposit = Setting.minimum_deposit
|
||||
Setting.minimum_deposit = 1.00
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
|
||||
Setting.minimum_deposit = @minimum_deposit
|
||||
end
|
||||
|
||||
def test_validate_amount_cannot_be_lower_than_0_01
|
||||
Setting.minimum_deposit = 0.0
|
||||
@deposit.amount = -10
|
||||
refute(@deposit.valid?)
|
||||
assert(@deposit.errors.full_messages.include?("Amount is too small. Minimum deposit is 0.01 EUR"))
|
||||
end
|
||||
|
||||
def test_validate_amount_cannot_be_lower_than_minimum_deposit
|
||||
@deposit.amount = 0.10
|
||||
refute(@deposit.valid?)
|
||||
|
||||
assert(@deposit.errors.full_messages.include?("Amount is too small. Minimum deposit is 1.0 EUR"))
|
||||
end
|
||||
|
||||
def test_registrar_must_be_set
|
||||
deposit = Deposit.new(amount: 120)
|
||||
refute(deposit.valid?)
|
||||
|
||||
assert(deposit.errors.full_messages.include?("Registrar is missing"))
|
||||
end
|
||||
|
||||
def test_amount_is_converted_from_string
|
||||
@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
|
||||
@deposit.amount = 12.0044
|
||||
assert_equal(BigDecimal.new("12.0044"), @deposit.amount)
|
||||
|
||||
@deposit.amount = 12.0144
|
||||
assert_equal(BigDecimal.new("12.0144"), @deposit.amount)
|
||||
end
|
||||
|
||||
def test_amount_is_converted_from_nil
|
||||
@deposit.amount = nil
|
||||
assert_equal(BigDecimal.new("0.00"), @deposit.amount)
|
||||
end
|
||||
end
|
|
@ -29,11 +29,10 @@ class NewInvoiceTest < ApplicationSystemTestCase
|
|||
assert_text 'Pay invoice'
|
||||
end
|
||||
|
||||
# This test case should fail once issue #651 gets fixed
|
||||
def test_create_new_invoice_with_amount_0_goes_through
|
||||
def test_create_new_invoice_with_comma_in_number
|
||||
visit registrar_invoices_path
|
||||
click_link_or_button 'Add deposit'
|
||||
fill_in 'Amount', with: '0.00'
|
||||
fill_in 'Amount', with: '200,00'
|
||||
fill_in 'Description', with: 'My first invoice'
|
||||
|
||||
assert_difference 'Invoice.count', 1 do
|
||||
|
@ -42,7 +41,33 @@ class NewInvoiceTest < ApplicationSystemTestCase
|
|||
|
||||
assert_text 'Please pay the following invoice'
|
||||
assert_text 'Invoice no. 131050'
|
||||
assert_text 'Subtotal 0,00 €'
|
||||
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'
|
||||
fill_in 'Amount', with: '0.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
|
||||
|
||||
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