Browse Source

Add get for individual product listing

Matt Scriven 8 years ago
parent
commit
76bb9cac6a
2 changed files with 94 additions and 2 deletions
  1. 86 0
      test/fixtures/product_listing.json
  2. 8 2
      test/product_listing_test.rb

+ 86 - 0
test/fixtures/product_listing.json

@@ -0,0 +1,86 @@
+{
+  "product_id": 2,
+  "created_at": "2017-01-06T14:52:56-05:00",
+  "updated_at": "2017-01-06T14:52:56-05:00",
+  "body_html": null,
+  "handle": "synergistic-silk-chair",
+  "product_type": "morph magnetic solutions",
+  "title": "Synergistic Silk Chair",
+  "vendor": "O'Hara, Fritsch and Hudson",
+  "available": true,
+  "tags": "",
+  "published_at": "2017-01-06T14:52:53-05:00",
+  "images": [
+
+  ],
+  "options": [
+    {
+      "id": 2,
+      "name": "Color or something",
+      "product_id": 2,
+      "position": 1
+    }
+  ],
+  "variants": [
+    {
+      "id": 3,
+      "title": "Aerodynamic Copper Clock",
+      "option_values": [
+        {
+          "option_id": 2,
+          "name": "Color or something",
+          "value": "Aerodynamic Copper Clock"
+        }
+      ],
+      "price": "179.99",
+      "formatted_price": "$179.99",
+      "compare_at_price": null,
+      "grams": 8400,
+      "requires_shipping": true,
+      "sku": "",
+      "barcode": null,
+      "taxable": true,
+      "position": 1,
+      "available": true,
+      "inventory_policy": "deny",
+      "inventory_quantity": 810,
+      "inventory_management": "shopify",
+      "fulfillment_service": "manual",
+      "weight": 8.4,
+      "weight_unit": "kg",
+      "image_id": null,
+      "created_at": "2017-01-04T17:07:47-05:00",
+      "updated_at": "2017-01-04T17:07:47-05:00"
+    },
+    {
+      "id": 4,
+      "title": "Awesome Concrete Knife",
+      "option_values": [
+        {
+          "option_id": 2,
+          "name": "Color or something",
+          "value": "Awesome Concrete Knife"
+        }
+      ],
+      "price": "179.99",
+      "formatted_price": "$179.99",
+      "compare_at_price": null,
+      "grams": 8400,
+      "requires_shipping": true,
+      "sku": "",
+      "barcode": null,
+      "taxable": true,
+      "position": 2,
+      "available": true,
+      "inventory_policy": "deny",
+      "inventory_quantity": 1,
+      "inventory_management": null,
+      "fulfillment_service": "manual",
+      "weight": 8.4,
+      "weight_unit": "kg",
+      "image_id": null,
+      "created_at": "2017-01-04T17:07:47-05:00",
+      "updated_at": "2017-01-04T17:07:47-05:00"
+    }
+  ]
+}

+ 8 - 2
test/product_listing_test.rb

@@ -5,14 +5,20 @@ class ProductListingTest < Test::Unit::TestCase
   def test_get_product_listings
     fake "applications/999/product_listings", method: :get, status: 201, body: load_fixture('product_listings')
 
-    product_listings = ShopifyAPI::ProductListing.find(:all, params: { application_id: 999})
+    product_listings = ShopifyAPI::ProductListing.find(:all, params: { application_id: 999 })
 
     assert_equal 2, product_listings.count
-
     assert_equal 2, product_listings.first.product_id
     assert_equal 1, product_listings.last.product_id
     assert_equal 'Synergistic Silk Chair', product_listings.first.title
     assert_equal 'Rustic Copper Bottle', product_listings.last.title
   end
 
+  def test_get_product_listing_for_product_id
+    fake "applications/999/product_listings/2", method: :get, status: 201, body: load_fixture('product_listing')
+
+    product_listing = ShopifyAPI::ProductListing.find(2, params: { application_id: 999 })
+
+    assert_equal 'Synergistic Silk Chair', product_listing.title
+  end
 end