mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-25 17:51:36 +01:00
Add worker spec for annual report worker (#31778)
This commit is contained in:
parent
5acec087ca
commit
09017dd8f0
1 changed files with 27 additions and 0 deletions
27
spec/workers/generate_annual_report_worker_spec.rb
Normal file
27
spec/workers/generate_annual_report_worker_spec.rb
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe GenerateAnnualReportWorker do
|
||||||
|
let(:worker) { described_class.new }
|
||||||
|
let(:account) { Fabricate :account }
|
||||||
|
|
||||||
|
describe '#perform' do
|
||||||
|
it 'generates new report for the account' do
|
||||||
|
expect { worker.perform(account.id, Date.current.year) }
|
||||||
|
.to change(account_reports, :count).by(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns true for non-existent record' do
|
||||||
|
result = worker.perform(123_123_123, Date.current.year)
|
||||||
|
|
||||||
|
expect(result).to be(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
def account_reports
|
||||||
|
GeneratedAnnualReport
|
||||||
|
.where(account: account)
|
||||||
|
.where(year: Date.current.year)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue