From 0b18b0dc0aecaf3438db6615440eda8b8aa30f26 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 17 Nov 2020 19:04:26 +0000 Subject: [PATCH] Include Calculator attributes in PaymentMethod nested attributes and DRY repeated code --- app/controllers/spree/admin/shipping_methods_controller.rb | 7 +------ app/services/permitted_attributes/payment_method.rb | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/app/controllers/spree/admin/shipping_methods_controller.rb b/app/controllers/spree/admin/shipping_methods_controller.rb index cace3feea4..2847ba220d 100644 --- a/app/controllers/spree/admin/shipping_methods_controller.rb +++ b/app/controllers/spree/admin/shipping_methods_controller.rb @@ -86,12 +86,7 @@ module Spree params.require(:shipping_method).permit( :name, :description, :display_on, :require_ship_address, :tag_list, :calculator_type, distributor_ids: [], - calculator_attributes: [ - :id, :preferred_currency, :preferred_amount, :preferred_unit_from_list, - :preferred_per_unit, :preferred_flat_percent, :preferred_first_item, - :preferred_additional_item, :preferred_max_items, :preferred_minimal_amount, - :preferred_normal_amount, :preferred_discount_amount - ] + calculator_attributes: PermittedAttributes::Calculator.attributes ) end end diff --git a/app/services/permitted_attributes/payment_method.rb b/app/services/permitted_attributes/payment_method.rb index bfe3238fb8..aac274a9f2 100644 --- a/app/services/permitted_attributes/payment_method.rb +++ b/app/services/permitted_attributes/payment_method.rb @@ -14,7 +14,7 @@ module PermittedAttributes :calculator_type, :preferred_api_key, :preferred_signature, :preferred_solution, :preferred_landing_page, :preferred_logourl, :preferred_test_mode, :calculator_type, { distributor_ids: [] }, - { calculator_attributes: [:id, :preferred_currency, :preferred_amount] }] + { calculator_attributes: PermittedAttributes::Calculator.attributes }] ) end end