Update OrderDetailedSerializer

This commit is contained in:
Matt-Yorkley
2021-02-10 20:32:31 +00:00
parent 80aefa8e73
commit 045cdec23c
2 changed files with 10 additions and 2 deletions

View File

@@ -5,8 +5,16 @@ module Api
has_one :bill_address, serializer: Api::AddressSerializer
has_many :line_items, serializer: Api::LineItemSerializer
has_many :adjustments, serializer: Api::AdjustmentSerializer
has_many :payments, serializer: Api::PaymentSerializer
attributes :adjustments
def adjustments
adjustments = object.all_adjustments.where(
"adjustable_type IN ('Spree::Order','Spree::Shipment')"
).order("label DESC")
ActiveModel::ArraySerializer.new(adjustments, each_serializer: Api::AdjustmentSerializer)
end
end
end

View File

@@ -248,7 +248,7 @@ module Api
)
expect(json_response[:adjustments].second).to include(
'label' => "Shipping",
'amount' => order.adjustments.shipping.first.amount.to_s
'amount' => order.shipment_adjustments.first.amount.to_s
)
expect(json_response[:payments].first[:amount]).to eq order.payments.first.amount.to_s