Parcourir la source

Add Custom Collection tests

Julio Napurí il y a 9 ans
Parent
commit
09df945686

+ 9 - 0
test/custom_collection_test.rb

@@ -0,0 +1,9 @@
+require 'test_helper'
+
+class CustomCollectionTest < Test::Unit::TestCase
+  test "#create should create a custom collection" do
+    fake "custom_collections", :method => :post, :status => 201, :body => load_fixture('custom_collection')
+    link = ShopifyAPI::CustomCollection.create(:title => "Macbooks", :image => { :src => "http://example.com/rails_logo.gif" })
+    assert_equal 1063001463, link.id
+  end
+end

+ 1 - 1
test/fixtures/collect.json

@@ -9,4 +9,4 @@
     "position": 1,
     "sort_value": "0000000001"
   }
-}
+}

+ 17 - 0
test/fixtures/custom_collection.json

@@ -0,0 +1,17 @@
+{
+  "custom_collection": {
+    "id": 1063001463,
+    "handle": "macbooks",
+    "title": "Macbooks",
+    "updated_at": "2016-03-17T16:58:37-04:00",
+    "body_html": null,
+    "published_at": "2016-03-17T16:58:37-04:00",
+    "sort_order": "alpha-asc",
+    "template_suffix": null,
+    "published_scope": "global",
+    "image": {
+      "created_at": "2016-03-17T16:58:37-04:00",
+      "src": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/collections\/fd43f2c8883f6e9b680e3295fd990d2c.gif?v=1458248317"
+    }
+  }
+}

+ 5 - 0
test/fixtures/smart_collection.json

@@ -11,6 +11,11 @@
     "published_scope": "global",
     "disjunctive": false,
     "rules": [
+      {
+        "column": "title",
+        "relation": "starts_with",
+        "condition": "mac"
+      }
     ]
   }
 }

+ 2 - 1
test/smart_collection_test.rb

@@ -3,7 +3,8 @@ require 'test_helper'
 class SmartCollectionTest < Test::Unit::TestCase
   test "Smart Collection creation" do
     fake "smart_collections", :method => :post, :status => 201, :body => load_fixture('smart_collection')
-    smart_collection = ShopifyAPI::SmartCollection.create(:title => "Macbooks", :published => false)
+    rules = { :column => "title", :relation => "starts_with", :condition => "mac" }
+    smart_collection = ShopifyAPI::SmartCollection.create(:title => "Macbooks", :rules => rules)
     assert_equal 1063001432, smart_collection.id
   end
 end