diff --git a/lib/strainer/behaviors/action_view_image_tag_changes.rb b/lib/strainer/behaviors/action_view_image_tag_changes.rb deleted file mode 100644 index 3880e21..0000000 --- a/lib/strainer/behaviors/action_view_image_tag_changes.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -module Strainer - module Behaviors - - class ActionViewImageTagChanges < Strainer::RuntimeBehavior - module HandleNilImageTagSrc - include Strainer::Logable - - def image_tag(source, options={}) - if source.nil? - strainer_log('IMAGE_TAG_SOURCE_NIL', custom: { source: source, options: options }) - return tag("img", options) - end - - super - end - end - - def apply_patch! - ActionView::Base.prepend(HandleNilImageTagSrc) - end - end - end -end diff --git a/lib/strainer/behaviors/mailer_with_path_helpers.rb b/lib/strainer/behaviors/mailer_with_path_helpers.rb deleted file mode 100644 index ecff902..0000000 --- a/lib/strainer/behaviors/mailer_with_path_helpers.rb +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -module Strainer - module Behaviors - # This module adds the ability to use path helpers on mailers - # This behavior was deprecated in https://github.com/rails/rails/commit/bd944e078d0f40e26d66b03da1449ff9cdcc101b - # and later removed - class MailerWithPathHelpers < Strainer::RuntimeBehavior - module SupportsPath - def supports_path? - true - end - end - - module PathHelpersWithLogging - def url_helpers(*args) - mod = super - wrapped_paths_module = wrap_module(mod) - mod.prepend(wrapped_paths_module) - end - - private - - # rubocop:disable Metrics/MethodLength this aint too long - def wrap_module(mod) - Module.new do - include Strainer::Logable - - mod.instance_methods.each do |method| - next unless method.to_s.ends_with?('_path') - - define_method(method) do |*arguments, &block| - if instance_variable_defined?(:@_controller) && @_controller.is_a?(ActionMailer::Base) - strainer_log('PATH_HELPER_IN_MAILER', custom: { helper_method: __method__ }) - end - super(*arguments, &block) - end - end - end - end - # rubocop:enable Metrics/MethodLength - end - - def apply_patch! - ActionMailer::Base.singleton_class.prepend(SupportsPath) - ActionDispatch::Routing::RouteSet.prepend(PathHelpersWithLogging) - end - end - end -end diff --git a/lib/strainer/behaviors/parameters_as_hash.rb b/lib/strainer/behaviors/parameters_as_hash.rb index 8516318..3fc8539 100644 --- a/lib/strainer/behaviors/parameters_as_hash.rb +++ b/lib/strainer/behaviors/parameters_as_hash.rb @@ -44,7 +44,7 @@ module ReConvertValue private - def convert_value(value, conversion: nil) + def convert_value(value, options = {}) return value if value.is_a? ActionController::Parameters super diff --git a/lib/strainer/behaviors/relation_query_method_changes.rb b/lib/strainer/behaviors/relation_query_method_changes.rb deleted file mode 100644 index 3b63368..0000000 --- a/lib/strainer/behaviors/relation_query_method_changes.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -require 'active_record' - -module Strainer - module Behaviors - # This module re-adds the 'aliases' (uniq and uniq!) on an active record relation that were removed in rails 6 - # It logs usages so that the code can be later corrected. - # eg User.where(conditions).admins.uniq - class RelationQueryMethodChanges < Strainer::RuntimeBehavior - module ReAliasUniqToDistinct - include Strainer::Logable - - def uniq(value = true) - strainer_log('RELATION_UNIQ', custom: { relation_method: 'uniq' }) - distinct(value) - end - - def uniq!(value = true) - strainer_log('RELATION_UNIQ!', custom: { relation_method: 'uniq!' }) - distinct!(value) - end - end - - def apply_patch! - ActiveRecord::Relation.include(ReAliasUniqToDistinct) - end - end - end -end diff --git a/lib/strainer/patches.rb b/lib/strainer/patches.rb index 4b0cbd2..438a022 100644 --- a/lib/strainer/patches.rb +++ b/lib/strainer/patches.rb @@ -19,17 +19,8 @@ def self.setup!(component) Behaviors::ForcedReloading, Behaviors::RelationDelegationChanges, Behaviors::FinderChanges, - Behaviors::RelationQueryMethodChanges, Behaviors::ActiveRecordBeforeCallbackChanges ) - when :action_mailer - load_behaviors( - Behaviors::MailerWithPathHelpers - ) - when :action_view - load_behaviors( - Behaviors::ActionViewImageTagChanges - ) end end # rubocop:enable Metrics/MethodLength