Make ReconciliationService logic more flexible for tests
The following discussion from !9261 should be addressed:
-
@ebaque started a discussion: (+1 comment) This is not the first time that I'm seeing this amount being updated in this spec file. A while ago, I tried to mitigate the need to update by adding some "flexibility" to an assertion:
# spec/services/reconciliations/order_api_spec.rb:72 # The amount_without_tax returned from Zuora can vary a bit based on number of days remaining in subscription (which can differ slightly based on whether remaining # months have 30 or 31 days). expect(invoice.amount_without_tax).to be_within(amount_without_tax * 0.01).of(amount_without_tax)This time around, how about then adding some related logic in the
ReconciliationService? Something like:# app/services/reconciliation_service.rb def raise_error(details) return if Rails.env.test? && diff_within_tolerance_for?(details) ... end def diff_within_tolerance_for?(details) (details[:quoted_invoice_amount] / details[:latest_preview_amount]).between?(0.99, 1.01) endWith something like this, we won't have to update this amount in the spec file periodically. WDYT?
Edited by Tatyana Golubeva