Merge pull request #13236 from mkllnk/deprecations

Alert us to deprecation warnings
This commit is contained in:
David Cook
2025-04-01 09:53:02 +11:00
committed by GitHub
3 changed files with 28 additions and 4 deletions

View File

@@ -52,7 +52,17 @@ Openfoodnetwork::Application.configure do
# config.active_record.schema_format = :sql
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr
# config.active_support.deprecation = :stderr
# Fail tests on deprecated code unless it's a known case to solve.
ActiveSupport::Deprecation.behavior = ->(message, callstack, deprecation_horizon, gem_name) do
allowed_warnings = [
# List strings here to allow matching deprecations.
]
unless allowed_warnings.any? { |pattern| message.match(pattern) }
ActiveSupport::Deprecation::DEFAULT_BEHAVIORS[:raise].call(message, callstack, deprecation_horizon, gem_name)
end
end
config.active_job.queue_adapter = :test
end

View File

@@ -0,0 +1,14 @@
# frozen_string_literal: true
ActiveSupport::Notifications.subscribe(/deprecation/) do |_name, _start, _finish, _id, payload|
e = ActiveSupport::DeprecationException.new(payload[:message])
e.set_backtrace(payload[:callstack].map(&:to_s))
Bugsnag.notify(e) do |report|
report.severity = "warning"
report.add_tab(
:deprecation,
payload.except(:callstack),
)
end
end

View File

@@ -21,15 +21,15 @@ module Reporting
private
def customer_payments_total_cost(line_items)
unique_orders(line_items).sum(&:total)
unique_orders(line_items).map(&:total).sum(&:to_f)
end
def customer_payments_amount_owed(line_items)
unique_orders(line_items).sum(&:new_outstanding_balance)
unique_orders(line_items).map(&:new_outstanding_balance).sum(&:to_f)
end
def customer_payments_amount_paid(line_items)
unique_orders(line_items).sum(&:payment_total)
unique_orders(line_items).map(&:payment_total).sum(&:to_f)
end
def unique_orders(line_items)