mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 21:54:48 +02:00
- `runner 'Invoice.cancel_overdue_invoices'` in `schedule.rb` is changed to `rake 'invoices:cancel_overdue'`. - `invoices.payment_term` database column is removed and its value is hardcoded in UI. - `invoices.paid_at` is removed as unused - `invoices.due_date` column's type is now `date`. - `Invoice#invoice_items` renamed to `Invoice#items` and `Invoice` interface to get a list of items is unified. - Default date format in UI. - Default translations are used. - Tests improved. - Specs converted to tests and removed along with factories. - Database structure improved.
41 lines
No EOL
926 B
Ruby
41 lines
No EOL
926 B
Ruby
require 'test_helper'
|
|
|
|
class CancelOverdueInvoicesTaskTest < ActiveSupport::TestCase
|
|
setup do
|
|
@invoice = invoices(:one)
|
|
eliminate_effect_of_other_invoices
|
|
end
|
|
|
|
def test_cancels_overdue_invoices
|
|
@invoice.update!(account_activity: nil, cancelled_at: nil, due_date: '2010-07-05')
|
|
assert @invoice.cancellable?
|
|
|
|
capture_io do
|
|
run_task
|
|
end
|
|
@invoice.reload
|
|
|
|
assert @invoice.cancelled?
|
|
end
|
|
|
|
def test_output
|
|
@invoice.update!(account_activity: nil, cancelled_at: nil, due_date: '2010-07-05')
|
|
assert @invoice.cancellable?
|
|
|
|
assert_output "Invoice ##{@invoice.id} is cancelled\nCancelled total: 1\n" do
|
|
run_task
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def eliminate_effect_of_other_invoices
|
|
Invoice.connection.disable_referential_integrity do
|
|
Invoice.delete_all("id != #{@invoice.id}")
|
|
end
|
|
end
|
|
|
|
def run_task
|
|
Rake::Task['invoices:cancel_overdue'].execute
|
|
end
|
|
end |