From 5b7f5ee61fe1580989a28ea6698983a4334f097c Mon Sep 17 00:00:00 2001 From: Ibrahim Diallo Date: Tue, 28 May 2019 17:05:55 -0700 Subject: [PATCH] add preferred_reimbursement_type_id as permitted attributes for the api --- .../spree/api/return_authorizations_controller_spec.rb | 8 ++++++++ core/lib/spree/permitted_attributes.rb | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/api/spec/requests/spree/api/return_authorizations_controller_spec.rb b/api/spec/requests/spree/api/return_authorizations_controller_spec.rb index 0baaf041d33..2dca448a065 100644 --- a/api/spec/requests/spree/api/return_authorizations_controller_spec.rb +++ b/api/spec/requests/spree/api/return_authorizations_controller_spec.rb @@ -17,13 +17,21 @@ module Spree it "can create a new return authorization" do stock_location = FactoryBot.create(:stock_location) reason = FactoryBot.create(:return_reason) + reimbursement = FactoryBot.create(:reimbursement_type) + unit = FactoryBot.create(:inventory_unit) rma_params = { stock_location_id: stock_location.id, return_reason_id: reason.id, + return_items_attributes: [{ + inventory_unit_id: unit.id, + preferred_reimbursement_type_id: reimbursement.id, + }], memo: "Defective" } post spree.api_order_return_authorizations_path(order), params: { order_id: order.number, return_authorization: rma_params } expect(response.status).to eq(201) expect(json_response).to have_attributes(attributes) expect(json_response["state"]).not_to be_blank + return_authorization = Spree::ReturnAuthorization.last + expect(return_authorization.return_items.first.preferred_reimbursement_type).to eql reimbursement end end diff --git a/core/lib/spree/permitted_attributes.rb b/core/lib/spree/permitted_attributes.rb index 97e69e0b831..2ed3106567c 100644 --- a/core/lib/spree/permitted_attributes.rb +++ b/core/lib/spree/permitted_attributes.rb @@ -79,7 +79,7 @@ module PermittedAttributes @@property_attributes = [:name, :presentation] - @@return_authorization_attributes = [:memo, :stock_location_id, :return_reason_id, return_items_attributes: [:inventory_unit_id, :exchange_variant_id, :return_reason_id]] + @@return_authorization_attributes = [:memo, :stock_location_id, :return_reason_id, return_items_attributes: [:inventory_unit_id, :exchange_variant_id, :return_reason_id, :preferred_reimbursement_type_id]] @@shipment_attributes = [ :special_instructions, :stock_location_id, :id, :tracking,