Skip to content

Commit

Permalink
feat(wallet): Prevent refreshing wallets that are not ready
Browse files Browse the repository at this point in the history
  • Loading branch information
rsempe committed Oct 14, 2024
1 parent a65c309 commit d7bd9e3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/jobs/clock/refresh_wallets_ongoing_balance_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/jobs/clock/refresh_wallets_ongoing_balance_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit d7bd9e3

Please sign in to comment.