mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Workaround Rails inheritance bug in Spree::Gateway
Due to a bug in ActiveRecord we need to load the tagging code in Gateway which should have inherited it from its parent PaymentMethod. We have to call it before loading the PaymentMethod decorator because the tagging code won't load twice within the inheritance chain. https://github.com/openfoodfoundation/openfoodnetwork/issues/3121
This commit is contained in:
@@ -8,6 +8,16 @@
|
||||
|
||||
require 'spree/product_filters'
|
||||
|
||||
# Due to a bug in ActiveRecord we need to load the tagging code in Gateway which
|
||||
# should have inherited it from its parent PaymentMethod.
|
||||
# We have to call it before loading the PaymentMethod decorator because the
|
||||
# tagging code won't load twice within the inheritance chain.
|
||||
# https://github.com/openfoodfoundation/openfoodnetwork/issues/3121
|
||||
Spree::Gateway.class_eval do
|
||||
acts_as_taggable
|
||||
attr_accessible :tag_list
|
||||
end
|
||||
|
||||
require "#{Rails.root}/app/models/spree/payment_method_decorator"
|
||||
require "#{Rails.root}/app/models/spree/gateway_decorator"
|
||||
|
||||
|
||||
27
spec/models/spree/gateway_tagging_spec.rb
Normal file
27
spec/models/spree/gateway_tagging_spec.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
require "spec_helper"
|
||||
|
||||
# An inheritance bug made these specs fail.
|
||||
# See config/initializers/spree.rb
|
||||
shared_examples "taggable" do |parameter|
|
||||
it "uses the given parameter" do
|
||||
expect(subject.tag_list).to eq []
|
||||
end
|
||||
end
|
||||
|
||||
module Spree
|
||||
describe PaymentMethod do
|
||||
it_behaves_like "taggable"
|
||||
end
|
||||
|
||||
describe Gateway do
|
||||
it_behaves_like "taggable"
|
||||
end
|
||||
|
||||
describe Gateway::PayPalExpress do
|
||||
it_behaves_like "taggable"
|
||||
end
|
||||
|
||||
describe Gateway::StripeConnect do
|
||||
it_behaves_like "taggable"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user