mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #13236 from mkllnk/deprecations
Alert us to deprecation warnings
This commit is contained in:
@@ -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
|
||||
|
||||
14
config/initializers/deprecations.rb
Normal file
14
config/initializers/deprecations.rb
Normal 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
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user