test/unit/invoice_test.rb in xero_gateway-2.6.0 vs test/unit/invoice_test.rb in xero_gateway-2.7.0
- old
+ new
@@ -95,43 +95,43 @@
def test_invoice_sub_total_calculation
invoice = create_test_invoice(:line_items_downloaded => true)
line_item = invoice.line_items.first
# Make sure that everything adds up to begin with.
- expected_sub_total = invoice.line_items.inject(BigDecimal.new('0')) { | sum, l | l.line_amount }
+ expected_sub_total = invoice.line_items.inject(BigDecimal('0')) { | sum, l | l.line_amount }
assert_equal(expected_sub_total, invoice.sub_total)
# Change the sub_total and check that it doesn't modify anything.
invoice.sub_total = expected_sub_total * 10
assert_equal(expected_sub_total, invoice.sub_total)
# Change the amount of the first line item and make sure that
# everything still continues to add up.
line_item.unit_amount = line_item.unit_amount + 10
assert_not_equal(expected_sub_total, invoice.sub_total)
- expected_sub_total = invoice.line_items.inject(BigDecimal.new('0')) { | sum, l | l.line_amount }
+ expected_sub_total = invoice.line_items.inject(BigDecimal('0')) { | sum, l | l.line_amount }
assert_equal(expected_sub_total, invoice.sub_total)
end
# Tests the total_tax calculation and that setting it manually doesn't modify the data.
def test_invoice_sub_total_calculation2
invoice = create_test_invoice(:line_items_downloaded => true)
line_item = invoice.line_items.first
# Make sure that everything adds up to begin with.
- expected_total_tax = invoice.line_items.inject(BigDecimal.new('0')) { | sum, l | l.tax_amount }
+ expected_total_tax = invoice.line_items.inject(BigDecimal('0')) { | sum, l | l.tax_amount }
assert_equal(expected_total_tax, invoice.total_tax)
# Change the total_tax and check that it doesn't modify anything.
invoice.total_tax = expected_total_tax * 10
assert_equal(expected_total_tax, invoice.total_tax)
# Change the tax_amount of the first line item and make sure that
# everything still continues to add up.
line_item.tax_amount = line_item.tax_amount + 10
assert_not_equal(expected_total_tax, invoice.total_tax)
- expected_total_tax = invoice.line_items.inject(BigDecimal.new('0')) { | sum, l | l.tax_amount }
+ expected_total_tax = invoice.line_items.inject(BigDecimal('0')) { | sum, l | l.tax_amount }
assert_equal(expected_total_tax, invoice.total_tax)
end
# Tests the total calculation and that setting it manually doesn't modify the data.
def test_invoice_sub_total_calculation3
@@ -200,13 +200,13 @@
def test_totalling_methods_when_line_items_empty
invoice = create_test_invoice
invoice.line_items = []
assert_nothing_raised(Exception) {
- assert_equal(BigDecimal.new('0'), invoice.sub_total)
- assert_equal(BigDecimal.new('0'), invoice.total_tax)
- assert_equal(BigDecimal.new('0'), invoice.total)
+ assert_equal(BigDecimal('0'), invoice.sub_total)
+ assert_equal(BigDecimal('0'), invoice.total_tax)
+ assert_equal(BigDecimal('0'), invoice.total)
}
end
def test_invoice_type_helper_methods
# Test accounts receivable invoices.
@@ -248,12 +248,12 @@
assert_equal('12345678', invoice.contact.phone.number)
# Test the line_item defaults.
assert_equal('A LINE ITEM', invoice.line_items.first.description)
assert_equal('200', invoice.line_items.first.account_code)
- assert_equal(BigDecimal.new('100'), invoice.line_items.first.unit_amount)
- assert_equal(BigDecimal.new('12.5'), invoice.line_items.first.tax_amount)
+ assert_equal(BigDecimal('100'), invoice.line_items.first.unit_amount)
+ assert_equal(BigDecimal('12.5'), invoice.line_items.first.tax_amount)
# Test optional params
assert_nil invoice.url
# Test overriding an invoice parameter (assume works for all).
@@ -268,22 +268,22 @@
# Test overriding line_items with hash.
invoice = create_test_invoice({}, {}, {:description => 'OVERRIDDEN LINE ITEM'})
assert_equal(1, invoice.line_items.size)
assert_equal('OVERRIDDEN LINE ITEM', invoice.line_items.first.description)
- assert_equal(BigDecimal.new('100'), invoice.line_items.first.unit_amount)
+ assert_equal(BigDecimal('100'), invoice.line_items.first.unit_amount)
# Test overriding line_items with array of 2 line_items.
invoice = create_test_invoice({}, {}, [
{:description => 'OVERRIDDEN ITEM 1'},
- {:description => 'OVERRIDDEN ITEM 2', :account_code => '200', :unit_amount => BigDecimal.new('200'), :tax_amount => '25.0'}
+ {:description => 'OVERRIDDEN ITEM 2', :account_code => '200', :unit_amount => BigDecimal('200'), :tax_amount => '25.0'}
])
assert_equal(2, invoice.line_items.size)
assert_equal('OVERRIDDEN ITEM 1', invoice.line_items[0].description)
- assert_equal(BigDecimal.new('100'), invoice.line_items[0].unit_amount)
+ assert_equal(BigDecimal('100'), invoice.line_items[0].unit_amount)
assert_equal('OVERRIDDEN ITEM 2', invoice.line_items[1].description)
- assert_equal(BigDecimal.new('200'), invoice.line_items[1].unit_amount)
+ assert_equal(BigDecimal('200'), invoice.line_items[1].unit_amount)
end
def test_auto_creation_of_associated_contact
invoice = create_test_invoice({}, nil) # no contact
assert(!invoice.instance_variable_defined?("@contact"))
@@ -389,11 +389,11 @@
# At least one line item, make first have some defaults.
line_item_params << {} if line_item_params.size == 0
line_item_params[0] = {
:description => "A LINE ITEM",
:account_code => "200",
- :unit_amount => BigDecimal.new("100"),
- :tax_amount => BigDecimal.new("12.5"),
+ :unit_amount => BigDecimal("100"),
+ :tax_amount => BigDecimal("12.5"),
:tracking => XeroGateway::TrackingCategory.new(:name => "blah", :options => "hello")
}.merge(line_item_params[0])
# Create invoice.line_items from line_item_params
line_item_params.each do | line_item |