From 2d7079c911c8c1bed3059b677a70f015b2d2aa90 Mon Sep 17 00:00:00 2001 From: Chris Todorov Date: Mon, 29 Mar 2021 13:37:58 -0700 Subject: [PATCH] Deprecate passing `return_items_attributes` in API as hash of hashes This is a behaviour which was previously undocumented worked because of the native Rails parameter parsing for nested attributes. This is not something we want to support through the API going forward so we are adding a deprecation warning for anyone using this behaviour currently. --- .../controllers/spree/api/customer_returns_controller.rb | 4 ++++ .../spree/api/customer_returns_controller_spec.rb | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/api/app/controllers/spree/api/customer_returns_controller.rb b/api/app/controllers/spree/api/customer_returns_controller.rb index 1e972222274..98d871bfbcc 100644 --- a/api/app/controllers/spree/api/customer_returns_controller.rb +++ b/api/app/controllers/spree/api/customer_returns_controller.rb @@ -71,6 +71,10 @@ def build_return_items_from_params if return_items_params.is_a? ActionController::Parameters return_items_params = return_items_params.values + Spree::Deprecation.warn( + "Passing `return_items_attributes` as a hash of hashes is \ +deprecated and will be removed in future versions of Solidus." + ) end @customer_return = CustomerReturn.new(customer_return_attributes) diff --git a/api/spec/requests/spree/api/customer_returns_controller_spec.rb b/api/spec/requests/spree/api/customer_returns_controller_spec.rb index 6b8bd31b41c..3ec07b1b499 100644 --- a/api/spec/requests/spree/api/customer_returns_controller_spec.rb +++ b/api/spec/requests/spree/api/customer_returns_controller_spec.rb @@ -189,6 +189,15 @@ module Spree expect(response).to have_http_status(:success) expect(json_response).to have_attributes(attributes) end + + it "logs a deprecation warning" do + expect(Spree::Deprecation). + to receive(:warn). + with( + /Passing `return_items_attributes` as a hash of hashes is deprecated/ + ) + subject + end end context "with reception_status_event provided for return item" do