diff --git a/app/jobs/clock/refresh_wallets_ongoing_balance_job.rb b/app/jobs/clock/refresh_wallets_ongoing_balance_job.rb index e419a1e819a6..994e27af7832 100644 --- a/app/jobs/clock/refresh_wallets_ongoing_balance_job.rb +++ b/app/jobs/clock/refresh_wallets_ongoing_balance_job.rb @@ -11,7 +11,7 @@ class RefreshWalletsOngoingBalanceJob < ApplicationJob def perform return unless License.premium? - Wallet.active.find_each do |wallet| + Wallet.ready_to_be_refreshed.find_each do |wallet| Wallets::RefreshOngoingBalanceJob.perform_later(wallet) end end diff --git a/spec/jobs/clock/refresh_wallets_ongoing_balance_job_spec.rb b/spec/jobs/clock/refresh_wallets_ongoing_balance_job_spec.rb index 9304ec4b165c..8b4f4d8ad6cb 100644 --- a/spec/jobs/clock/refresh_wallets_ongoing_balance_job_spec.rb +++ b/spec/jobs/clock/refresh_wallets_ongoing_balance_job_spec.rb @@ -8,7 +8,7 @@ describe '.perform' do let(:organization) { create(:organization) } let(:customer) { create(:customer, organization:) } - let(:wallet) { create(:wallet, customer:) } + let(:wallet) { create(:wallet, customer:, ready_to_be_refreshed: true) } before do wallet @@ -30,8 +30,8 @@ expect(Wallets::RefreshOngoingBalanceJob).to have_been_enqueued.with(wallet) end - context 'when not active' do - let(:wallet) { create(:wallet, :terminated) } + context 'when not ready to be refreshed' do + let(:wallet) { create(:wallet, customer:, ready_to_be_refreshed: false) } it 'does not call the refresh service' do described_class.perform_now