Replace custom lookup with default Rails feature

Rails renders an error when you try to supply an invalid value. Our code
is safe without an allow-list and the UX doesn't allow you to select an
invalid value.
This commit is contained in:
Maikel Linke
2026-01-09 14:33:39 +11:00
parent 41a8d06326
commit cb7a4b67ce
2 changed files with 1 additions and 12 deletions

View File

@@ -95,7 +95,7 @@ module Spree
@payment_method = PaymentMethod.find(params[:pm_id])
end
else
@payment_method = PAYMENT_METHODS.fetch(params[:provider_type], PaymentMethod).new
@payment_method = PaymentMethod.new(type: params[:provider_type])
end
render partial: 'provider_settings'

View File

@@ -296,17 +296,6 @@ RSpec.describe Spree::Admin::PaymentMethodsController do
expect(assigns(:payment_method)).to be_a_new Spree::Gateway::PayPalExpress
expect(response).to render_template partial: '_provider_settings'
end
context "with a non valid payment method" do
it "renders provider settings with a new generic payment method" do
spree_get :show_provider_preferences,
pm_id: "",
provider_type: "Spree::Gateway::Hacked"
expect(assigns(:payment_method)).to be_a_new Spree::PaymentMethod
expect(response).to render_template partial: '_provider_settings'
end
end
end
end
end