浏览代码

Merge pull request #251 from julionc/tests

Add missing Tests
Kevin Hughes 9 年之前
父节点
当前提交
ad31dc4303

+ 9 - 0
test/collect_test.rb

@@ -0,0 +1,9 @@
+require 'test_helper'
+
+class CollectTest < Test::Unit::TestCase
+  test "#create should create a collect" do
+    fake "collects", :method => :post, :status => 201, :body => load_fixture('collect')
+    link = ShopifyAPI::Collect.create(:product_id => 921728736, :collection_id => 841564295)
+    assert_equal 841564295, link.id
+  end
+end

+ 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

+ 12 - 0
test/fixtures/collect.json

@@ -0,0 +1,12 @@
+{
+  "collect": {
+    "id": 841564295,
+    "collection_id": 841564295,
+    "product_id": 632910392,
+    "featured": false,
+    "created_at": null,
+    "updated_at": null,
+    "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"
+    }
+  }
+}

+ 7 - 0
test/fixtures/redirect.json

@@ -0,0 +1,7 @@
+{
+  "redirect": {
+    "id": 979034150,
+    "path": "\/ipod",
+    "target": "\/pages\/itunes"
+  }
+}

+ 21 - 0
test/fixtures/smart_collection.json

@@ -0,0 +1,21 @@
+{
+  "smart_collection": {
+    "id": 1063001432,
+    "handle": "macbooks",
+    "title": "Macbooks",
+    "updated_at": "2016-03-17T16:57:03-04:00",
+    "body_html": null,
+    "published_at": null,
+    "sort_order": "alpha-asc",
+    "template_suffix": null,
+    "published_scope": "global",
+    "disjunctive": false,
+    "rules": [
+      {
+        "column": "title",
+        "relation": "starts_with",
+        "condition": "mac"
+      }
+    ]
+  }
+}

+ 9 - 0
test/redirect_test.rb

@@ -0,0 +1,9 @@
+require 'test_helper'
+
+class RedirectTest < Test::Unit::TestCase
+  test "#create should create a redirect" do
+    fake "redirects", :method => :post, :status => 201, :body => load_fixture('redirect')
+    redirect = ShopifyAPI::Redirect.create(:path => "/ipod", :target => "/pages/itunes")
+    assert_equal 979034150, redirect.id
+  end
+end

+ 10 - 0
test/smart_collection_test.rb

@@ -0,0 +1,10 @@
+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')
+    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