mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-12 23:09:03 +01:00
44 lines
1.1 KiB
Ruby
44 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'test_helper'
|
|
require 'minitest/autorun'
|
|
require 'sidekiq/testing'
|
|
|
|
class AccountingWorkerTest < ActiveSupport::TestCase
|
|
setup do
|
|
Sidekiq::Testing.inline!
|
|
@worker = AccountingWorker.new
|
|
end
|
|
|
|
teardown do
|
|
Sidekiq::Testing.fake!
|
|
end
|
|
|
|
test 'build accounting lines for yesterday by default' do
|
|
date = Time.current.midnight
|
|
travel_to(date)
|
|
@worker.perform
|
|
assert_match(/^yesterday:/, @worker.performed)
|
|
assert_match(date.yesterday.to_date.iso8601, @worker.performed)
|
|
end
|
|
|
|
test 'build accounting lines for today' do
|
|
@worker.perform(:today)
|
|
assert_match(/^today:/, @worker.performed)
|
|
assert_match(Time.current.to_date.iso8601, @worker.performed)
|
|
end
|
|
|
|
test 'build specified invoices selection' do
|
|
ids = [5820, 5821, 5822]
|
|
@worker.perform(:invoices, ids)
|
|
assert_match(/^invoices:/, @worker.performed)
|
|
assert_match(ids.to_s, @worker.performed)
|
|
end
|
|
|
|
test 'build all invoices' do
|
|
@worker.perform(:all)
|
|
assert_match(/^all:/, @worker.performed)
|
|
assert_match(Invoice.all.map(&:id).to_s, @worker.performed)
|
|
end
|
|
end
|