Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[api] Add product properties as child of Products

Merges #1568
  • Loading branch information...
commit a93289d3119ba00663371f84b19addedf2386690 1 parent 6e2bfe9
Greg Morrison jeebster authored radar committed
4 api/app/helpers/spree/api/api_helpers.rb
View
@@ -16,6 +16,10 @@ def product_attributes
:count_on_hand, :meta_description, :meta_keywords, :taxon_ids]
end
+ def product_property_attributes
+ [:id, :product_id, :property_id, :value, :property_name]
+ end
+
def variant_attributes
[:id, :name, :count_on_hand, :sku, :price, :weight, :height, :width, :depth, :is_master, :cost_price, :permalink]
end
4 api/app/views/spree/api/v1/products/show.rabl
View
@@ -19,3 +19,7 @@ child :option_types => :option_types do
attributes *option_value_attributes
end
end
+
+child :product_properties => :product_properties do
+ attributes *product_property_attributes
+end
5 api/spec/controllers/spree/api/v1/products_controller_spec.rb
View
@@ -48,6 +48,7 @@ module Spree
it "gets a single product" do
product.master.images.create!(:attachment => image("thinking-cat.jpg"))
+ product.set_property("spree", "rocks")
api_get :show, :id => product.to_param
json_response.should have_attributes(attributes)
product_json = json_response["product"]
@@ -60,6 +61,10 @@ module Spree
:attachment_width,
:attachment_height,
:attachment_content_type])
+
+ product_json["product_properties"].first.should have_attributes([:value,
+ :product_id,
+ :property_name])
end
Please sign in to comment.
Something went wrong with that request. Please try again.