1
0

Add worker spec for annual report worker (#31778)

This commit is contained in:
Matt Jankowski 2024-09-05 15:51:17 -04:00 committed by GitHub
parent 5acec087ca
commit 09017dd8f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View 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