Merge pull request #1522 from internetee/1521-big-decimal-deprecation-warning

Get rid of BigDecimal.new deprecation warning
This commit is contained in:
Timo Võhmar 2020-02-10 13:14:16 +02:00 committed by GitHub
commit 76de81d70f
5 changed files with 11 additions and 9 deletions

View file

@ -45,7 +45,7 @@ class BankStatement < ApplicationRecord
buyer_name: row[83, 35].strip, buyer_name: row[83, 35].strip,
document_no: row[118, 8].strip, document_no: row[118, 8].strip,
description: row[126, 140].strip, description: row[126, 140].strip,
sum: BigDecimal.new(row[268, 12].strip) / BigDecimal.new('100.0'), sum: BigDecimal(row[268, 12].strip) / BigDecimal('100.0'),
reference_no: row[280, 35].strip reference_no: row[280, 35].strip
} }
end end

View file

@ -89,7 +89,7 @@ module PaymentOrders
def valid_amount? def valid_amount?
source = number_with_precision( source = number_with_precision(
BigDecimal.new(response["VK_AMOUNT"]), precision: 2, separator: "." BigDecimal(response["VK_AMOUNT"]), precision: 2, separator: "."
) )
target = number_with_precision( target = number_with_precision(
invoice.total, precision: 2, separator: "." invoice.total, precision: 2, separator: "."

View file

@ -76,7 +76,7 @@ module PaymentOrders
end end
def valid_amount? def valid_amount?
invoice.total == BigDecimal.new(response[:amount]) invoice.total == BigDecimal(response[:amount])
end end
def valid_account? def valid_account?

View file

@ -1,4 +1,6 @@
Rails.application.configure do Rails.application.configure do
$VERBOSE = nil
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's # The test environment is used exclusively to run your application's
@ -30,7 +32,7 @@ Rails.application.configure do
config.action_mailer.raise_delivery_errors = false config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the stderr. # Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr config.active_support.deprecation = :silence
# Raises error for missing translations # Raises error for missing translations
config.action_view.raise_on_missing_translations = true config.action_view.raise_on_missing_translations = true

View file

@ -36,22 +36,22 @@ class DepositTest < ActiveSupport::TestCase
def test_amount_is_converted_from_string def test_amount_is_converted_from_string
@deposit.amount = "12.00" @deposit.amount = "12.00"
assert_equal(BigDecimal.new("12.00"), @deposit.amount) assert_equal(BigDecimal("12.00"), @deposit.amount)
@deposit.amount = "12,11" @deposit.amount = "12,11"
assert_equal(BigDecimal.new("12.11"), @deposit.amount) assert_equal(BigDecimal("12.11"), @deposit.amount)
end end
def test_amount_is_converted_from_float def test_amount_is_converted_from_float
@deposit.amount = 12.0044 @deposit.amount = 12.0044
assert_equal(BigDecimal.new("12.0044"), @deposit.amount) assert_equal(BigDecimal("12.0044"), @deposit.amount)
@deposit.amount = 12.0144 @deposit.amount = 12.0144
assert_equal(BigDecimal.new("12.0144"), @deposit.amount) assert_equal(BigDecimal("12.0144"), @deposit.amount)
end end
def test_amount_is_converted_from_nil def test_amount_is_converted_from_nil
@deposit.amount = nil @deposit.amount = nil
assert_equal(BigDecimal.new("0.00"), @deposit.amount) assert_equal(BigDecimal("0.00"), @deposit.amount)
end end
end end