Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Add return_quantity to permitted attributes for return items (#13885)

Kenta Ishizakie06ebe675f68
diff --git a/spree/core/lib/spree/permitted_attributes.rb b/spree/core/lib/spree/permitted_attributes.rb
index 248e1c4637..02f438242b 100644
--- a/spree/core/lib/spree/permitted_attributes.rb
+++ b/spree/core/lib/spree/permitted_attributes.rb
@@ -115,7 +115,7 @@ module Spree
@@customer_return_attributes = [:stock_location_id, {
return_items_attributes: [:id, :inventory_unit_id, :return_authorization_id, :returned, :pre_tax_amount,
- :acceptance_status, :exchange_variant_id, :resellable]
+ :acceptance_status, :exchange_variant_id, :resellable, :return_quantity]
}]
@@digital_attributes = [:attachment, :variant_id]
@@ -222,14 +222,14 @@ module Spree
:id, :inventory_unit_id,
:preferred_reimbursement_type_id,
:return_authorization_id, :returned, :pre_tax_amount,
- :acceptance_status, :exchange_variant_id, :resellable
+ :acceptance_status, :exchange_variant_id, :resellable, :return_quantity
]
}
]
@@return_authorization_reason_attributes = [:name, :active]
- @@return_item_attributes = [:inventory_unit_id, :return_authorization_id, :returned, :pre_tax_amount, :acceptance_status, :exchange_variant_id, :resellable]
+ @@return_item_attributes = [:inventory_unit_id, :return_authorization_id, :returned, :pre_tax_amount, :acceptance_status, :exchange_variant_id, :resellable, :return_quantity]
@@role_attributes = [:name]
diff --git a/spree/core/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb b/spree/core/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb
index 384479cbc0..7ea389e98f 100644
--- a/spree/core/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb
+++ b/spree/core/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb
@@ -42,4 +42,19 @@ describe Spree::Core::ControllerHelpers::StrongParameters, type: :controller do
expect(controller.permitted_store_attributes.class).to eq Array
end
end
+
+ # Regression test for #13003
+ describe 'return_quantity in permitted attributes' do
+ it 'includes return_quantity in return_authorization nested return_items_attributes' do
+ nested = Spree::PermittedAttributes.return_authorization_attributes.find { |a| a.is_a?(Hash) && a.key?(:return_items_attributes) }
+ expect(nested).not_to be_nil
+ expect(nested[:return_items_attributes]).to include(:return_quantity)
+ end
+
+ it 'includes return_quantity in customer_return nested return_items_attributes' do
+ nested = Spree::PermittedAttributes.customer_return_attributes.find { |a| a.is_a?(Hash) && a.key?(:return_items_attributes) }
+ expect(nested).not_to be_nil
+ expect(nested[:return_items_attributes]).to include(:return_quantity)
+ end
+ end
end