diff --git a/app/models/spree/gateway.rb b/app/models/spree/gateway.rb index 2cbfc76a15..c480d9c251 100644 --- a/app/models/spree/gateway.rb +++ b/app/models/spree/gateway.rb @@ -5,7 +5,7 @@ module Spree acts_as_taggable include PaymentMethodDistributors - delegate :authorize, :purchase, :capture, :void, :credit, to: :provider + delegate :authorize, :purchase, :capture, :void, :credit, :refund, to: :provider validates :name, :type, presence: true @@ -35,6 +35,10 @@ module Spree end def method_missing(method, *) + message = "Deprecated delegation of Gateway##{method}" + Alert.raise(message) + raise message if Rails.env.local? + if @provider.nil? || !@provider.respond_to?(method) super else diff --git a/spec/models/spree/gateway_spec.rb b/spec/models/spree/gateway_spec.rb index 0b46238436..f6e975ba38 100644 --- a/spec/models/spree/gateway_spec.rb +++ b/spec/models/spree/gateway_spec.rb @@ -14,8 +14,14 @@ RSpec.describe Spree::Gateway do end it "passes through all arguments on a method_missing call" do + expect(Rails.env).to receive(:local?).and_return(false) gateway = test_gateway.new expect(gateway.provider).to receive(:imaginary_method).with('foo') gateway.imaginary_method('foo') end + + it "raises an error in test env" do + gateway = test_gateway.new + expect { gateway.imaginary_method('foo') }.to raise_error StandardError + end end