Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move concern to concerns directory #6021

Merged
merged 2 commits into from Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions app/models/concerns/payment_method_distributors.rb
@@ -0,0 +1,19 @@
# frozen_string_literal: true

require 'active_support/concern'

# This concern is used to duplicate the associations distributors and distributor_ids
# across payment method and gateway
# this fixes the inheritance problem https://github.com/openfoodfoundation/openfoodnetwork/issues/2781
module PaymentMethodDistributors
extend ActiveSupport::Concern

def self.included(base)
base.class_eval do
has_and_belongs_to_many :distributors, join_table: 'distributors_payment_methods',
class_name: 'Enterprise',
foreign_key: 'payment_method_id',
association_foreign_key: 'distributor_id'
end
end
end
16 changes: 0 additions & 16 deletions app/models/spree/concerns/payment_method_distributors.rb

This file was deleted.

4 changes: 1 addition & 3 deletions app/models/spree/gateway.rb
@@ -1,10 +1,8 @@
# frozen_string_literal: true

require 'spree/concerns/payment_method_distributors'

module Spree
class Gateway < PaymentMethod
include Spree::PaymentMethodDistributors
include PaymentMethodDistributors

delegate_belongs_to :provider, :authorize, :purchase, :capture, :void, :credit

Expand Down
4 changes: 1 addition & 3 deletions app/models/spree/payment_method.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: true

require 'spree/concerns/payment_method_distributors'

module Spree
class PaymentMethod < ActiveRecord::Base
include Spree::Core::CalculatedAdjustments
include Spree::PaymentMethodDistributors
include PaymentMethodDistributors

acts_as_taggable
acts_as_paranoid
Expand Down