Skip to content

Commit

Permalink
Corrected test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergei Tsoganov authored and Sergei Tsoganov committed Mar 16, 2023
1 parent 37c16a0 commit ec203df
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
8 changes: 8 additions & 0 deletions app/models/bank_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ class BankTransaction < ApplicationRecord
where('id NOT IN (SELECT bank_transaction_id FROM account_activities where bank_transaction_id IS NOT NULL)')
}

def self.ransackable_associations(auth_object = nil)
super
end

def self.ransackable_attributes(auth_object = nil)
super
end

def binded?
account_activity.present?
end
Expand Down
21 changes: 7 additions & 14 deletions test/models/invoice_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,20 @@ def test_calculates_vat_amount
end

def test_calculates_subtotal
line_item = InvoiceItem.new
invoice = Invoice.new(items: [line_item, line_item])

line_item.stub(:item_sum_without_vat, BigDecimal('2.5')) do
assert_equal BigDecimal(5), invoice.subtotal
end
line_item = InvoiceItem.new(price: BigDecimal('2.5'), quantity: 1)
invoice = Invoice.new(items: [line_item, line_item.dup])
assert_equal BigDecimal(5), invoice.subtotal
end

def test_returns_persisted_total
assert_equal BigDecimal('16.50'), @invoice.total
end

def test_calculates_total
line_item = InvoiceItem.new
invoice = Invoice.new
invoice.vat_rate = 10
invoice.items = [line_item, line_item]

line_item.stub(:item_sum_without_vat, BigDecimal('2.5')) do
assert_equal BigDecimal('5.50'), invoice.total
end
line_item = InvoiceItem.new(price: BigDecimal('2.5'), quantity: 1)
invoice = Invoice.new(vat_rate: 10)
invoice.items = [line_item, line_item.dup]
assert_equal BigDecimal('5.50'), invoice.total
end

def test_valid_without_buyer_vat_no
Expand Down

0 comments on commit ec203df

Please sign in to comment.