Skip to content

Commit

Permalink
Get rid of BigDecimal.new deprecation warning
Browse files Browse the repository at this point in the history
See #1521
  • Loading branch information
yulgolem committed Feb 7, 2020
1 parent 5fc8b37 commit a896881
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/models/bank_statement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def parse_th6_row(row)
buyer_name: row[83, 35].strip,
document_no: row[118, 8].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
}
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/payment_orders/bank_link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def valid_success_notice?

def valid_amount?
source = number_with_precision(
BigDecimal.new(response["VK_AMOUNT"]), precision: 2, separator: "."
BigDecimal(response["VK_AMOUNT"]), precision: 2, separator: "."
)
target = number_with_precision(
invoice.total, precision: 2, separator: "."
Expand Down
2 changes: 1 addition & 1 deletion app/models/payment_orders/every_pay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def valid_hmac?
end

def valid_amount?
invoice.total == BigDecimal.new(response[:amount])
invoice.total == BigDecimal(response[:amount])
end

def valid_account?
Expand Down
10 changes: 5 additions & 5 deletions test/models/deposit_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ def test_registrar_must_be_set

def test_amount_is_converted_from_string
@deposit.amount = "12.00"
assert_equal(BigDecimal.new("12.00"), @deposit.amount)
assert_equal(BigDecimal("12.00"), @deposit.amount)

@deposit.amount = "12,11"
assert_equal(BigDecimal.new("12.11"), @deposit.amount)
assert_equal(BigDecimal("12.11"), @deposit.amount)
end

def test_amount_is_converted_from_float
@deposit.amount = 12.0044
assert_equal(BigDecimal.new("12.0044"), @deposit.amount)
assert_equal(BigDecimal("12.0044"), @deposit.amount)

@deposit.amount = 12.0144
assert_equal(BigDecimal.new("12.0144"), @deposit.amount)
assert_equal(BigDecimal("12.0144"), @deposit.amount)
end

def test_amount_is_converted_from_nil
@deposit.amount = nil
assert_equal(BigDecimal.new("0.00"), @deposit.amount)
assert_equal(BigDecimal("0.00"), @deposit.amount)
end
end

0 comments on commit a896881

Please sign in to comment.