Skip to content

Commit

Permalink
Deprecate passing return_items_attributes in API as hash of hashes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
forkata committed Mar 29, 2021
1 parent b870d6a commit 2d7079c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/app/controllers/spree/api/customer_returns_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2d7079c

Please sign in to comment.