mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-06 22:36:07 +00:00
Update OrderDetailedSerializer
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user