Skip to content

Commit

Permalink
Spec for customer return referencing existing items
Browse files Browse the repository at this point in the history
This change adds a pending test which demonstrates an issue with the
`create` action when attempting to pass a reference to existing return
items from a previously created return authorization. Rails does not
allow us to update the association on the return items to the customer
return while creating the return.

Co-authored-by: Mike Conlin <mike@super.gd>
  • Loading branch information
forkata and Mike Conlin committed Mar 25, 2021
1 parent ea944ed commit 6f72204
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions api/spec/requests/spree/api/customer_returns_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,43 @@ module Spree
end
end

context "when referencing existing return items" do
subject do
post(
spree.api_order_customer_returns_path(order),
params: {
order_id: order.number,
customer_return: customer_return_params
}
)
end

let(:stock_location) { create(:stock_location) }
let(:inventory_unit) { create(:inventory_unit, state: "shipped") }
let(:return_item) do
create(:return_item, inventory_unit: inventory_unit)
end

let(:customer_return_params) do
{
stock_location_id: stock_location.id,
return_items_attributes: [
return_item.attributes.merge(reception_status_event: "receive")
]
}
end

it "can create a new customer return" do
pending("fix for referrencing existing return items")
subject

expect(response).to have_http_status(:success)
expect(json_response).to have_attributes(attributes)

customer_return = Spree::CustomerReturn.last

expect(customer_return.return_items.first.reception_status).to eql "received"
end
end
end
end
Expand Down

0 comments on commit 6f72204

Please sign in to comment.