Skip to content

Commit ae0327e

Browse files
committed
Add tests
1 parent 89ef32e commit ae0327e

File tree

8 files changed

+238
-483
lines changed

8 files changed

+238
-483
lines changed

.junie/guidelines.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

app/services/wallets/balance/refresh_ongoing_service.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ def assign_wallet_per_fee(fees)
101101
fees.each do |fee|
102102
key = fee.id || fee.object_id
103103

104-
applicable_wallets = Wallets::FindApplicableOnFeesService.call!(
105-
allocation_rules:, fee:, first_match: true
106-
).applicable_wallets
104+
applicable_wallets = Wallets::FindApplicableOnFeesService
105+
.call!(allocation_rules:, fee:)
106+
.applicable_wallets
107107

108108
fee_wallet[key] = applicable_wallets.presence
109109
end

app/services/wallets/balance/refresh_ongoing_usage_service.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ def assign_wallet_per_fee(fees)
7878
fees.each do |fee|
7979
key = fee.id || fee.object_id
8080

81-
applicable_wallets = Wallets::FindApplicableOnFeesService.call!(
82-
allocation_rules:, fee:, first_match: true
83-
).applicable_wallets
81+
applicable_wallets = Wallets::FindApplicableOnFeesService
82+
.call!(allocation_rules:, fee:)
83+
.applicable_wallets
8484

8585
fee_wallet[key] = applicable_wallets.presence
8686
end

app/services/wallets/build_allocation_rules_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def add_all_unique(target_array, source_array)
6464
end
6565

6666
def wallets
67-
@wallets ||= customer.active_wallets_in_application_order
67+
@wallets ||= customer.wallets.active.in_application_order
6868
.includes(wallet_targets: :billable_metric)
6969
end
7070

app/services/wallets/find_applicable_on_fees_service.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
module Wallets
44
class FindApplicableOnFeesService < BaseService
5-
def initialize(allocation_rules:, fee:, first_match: false)
5+
def initialize(allocation_rules:, fee:)
66
@allocation_rules = allocation_rules
77
@fee = fee
8-
@first_match = first_match
98
super
109
end
1110

@@ -26,10 +25,10 @@ def call
2625

2726
private
2827

29-
attr_reader :allocation_rules, :fee, :first_match
28+
attr_reader :allocation_rules, :fee
3029

3130
def result_with(wallets)
32-
result.applicable_wallets = first_match ? wallets.first : wallets
31+
result.applicable_wallets = wallets.first
3332
result
3433
end
3534
end

0 commit comments

Comments
 (0)