mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-04 02:31:33 +00:00
Update type handling in PaymentMethodsController and add tests
This commit is contained in:
@@ -33,7 +33,7 @@ module Spree
|
||||
|
||||
invoke_callbacks(:update, :before)
|
||||
|
||||
if @payment_method['type'].to_s != payment_method_class
|
||||
if @payment_method.type.to_s != payment_method_class
|
||||
@payment_method.update_columns(
|
||||
type: payment_method_class,
|
||||
updated_at: Time.zone.now
|
||||
@@ -97,7 +97,7 @@ module Spree
|
||||
private
|
||||
|
||||
def payment_method_class
|
||||
base_params.delete(:type)
|
||||
@payment_method_class ||= base_params.delete(:type)
|
||||
end
|
||||
|
||||
def force_environment
|
||||
|
||||
@@ -81,6 +81,23 @@ module Spree
|
||||
expect(payment_method.calculator.preferred_amount).to eq 456
|
||||
expect(payment_method.calculator.preferred_currency).to eq "GBP"
|
||||
end
|
||||
|
||||
context "when the given payment method type does not match" do
|
||||
let(:params) {
|
||||
{
|
||||
id: payment_method.id,
|
||||
payment_method: {
|
||||
type: "Spree::Gateway::Bogus"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it "updates the payment method type" do
|
||||
spree_post :update, params
|
||||
|
||||
expect(PaymentMethod.find(payment_method.id).type).to eq "Spree::Gateway::Bogus"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "on a StripeConnect payment method" do
|
||||
|
||||
Reference in New Issue
Block a user