mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-11 03:40:20 +00:00
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:
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user