Skip to content

Commit

Permalink
[api] Ensure total_quantity and display_item_total are available on o…
Browse files Browse the repository at this point in the history
…rders/index and orders/show
  • Loading branch information
radar committed Jun 8, 2013
1 parent 63f0217 commit 221b1b3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/app/views/spree/api/orders/index.v1.rabl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
object false
child(@orders => :orders) do
attributes *order_attributes
extends "spree/api/orders/order"
end
node(:count) { @orders.count }
node(:current_page) { params[:page] || 1 }
Expand Down
3 changes: 3 additions & 0 deletions api/app/views/spree/api/orders/order.v1.rabl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
attributes *order_attributes
node(:display_item_total) { |o| o.display_item_total.to_s }
node(:total_quantity) { |o| o.line_items.sum(:quantity) }
3 changes: 1 addition & 2 deletions api/app/views/spree/api/orders/show.v1.rabl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
object @order
attributes *order_attributes
node(:display_item_total) { |o| o.display_item_total.to_s }
extends "spree/api/orders/order"

if lookup_context.find_all("spree/api/orders/#{@order.state}").present?
extends "spree/api/orders/#{@order.state}"
Expand Down
3 changes: 2 additions & 1 deletion api/spec/controllers/spree/api/orders_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ module Spree
:state, :adjustment_total,
:user_id, :created_at, :updated_at,
:completed_at, :payment_total, :shipment_state,
:payment_state, :email, :special_instructions] }
:payment_state, :email, :special_instructions,
:total_quantity, :display_item_total] }


before do
Expand Down

0 comments on commit 221b1b3

Please sign in to comment.