Make tag_rulee_applicator and available_payment_methods_filter handle case where a relation is given instead of an array

This commit is contained in:
Luis Ramos
2020-05-19 18:45:35 +01:00
parent 1dace1f0e3
commit 7e606471e4
3 changed files with 4 additions and 3 deletions

View File

@@ -2,9 +2,9 @@ module OpenFoodNetwork
class AvailablePaymentMethodFilter
def filter!(payment_methods)
if stripe_enabled?
payment_methods.reject!{ |p| p.type.ends_with?("StripeConnect") && stripe_configuration_incomplete?(p) }
payment_methods.to_a.reject!{ |p| p.type.ends_with?("StripeConnect") && stripe_configuration_incomplete?(p) }
else
payment_methods.reject!{ |p| p.type.ends_with?("StripeConnect") }
payment_methods.to_a.reject!{ |p| p.type.ends_with?("StripeConnect") }
end
end

View File

@@ -14,7 +14,7 @@ module OpenFoodNetwork
def filter!(subject)
return unless subject.respond_to?(:any?) && subject.any?
subject.reject! do |element|
subject.to_a.reject! do |element|
if rule_class.respond_to?(:tagged_children_for)
children = rule_class.tagged_children_for(element)
children.reject! { |child| reject?(child) }

View File

@@ -1,4 +1,5 @@
require 'open_food_network/tag_rule_applicator'
require 'spec_helper'
module OpenFoodNetwork
describe TagRuleApplicator do