Browse Source

Adds policy model

Chris Saunders 10 years ago
parent
commit
b6afcd9ff1

+ 7 - 0
lib/shopify_api/resources/policy.rb

@@ -0,0 +1,7 @@
+module ShopifyAPI
+  class Policy < Base
+    def self.all
+      find(:all)
+    end
+  end
+end

+ 2 - 2
lib/shopify_api/resources/shop.rb

@@ -3,9 +3,9 @@ module ShopifyAPI
   # the shop.
   class Shop < Base
     def self.current
-      find(:one, :from => "/admin/shop.#{format.extension}")
+      find(:one, from: "/admin/shop.#{format.extension}")
     end
-    
+
     def metafields
       Metafield.find(:all)
     end

+ 8 - 0
test/fixtures/policies.json

@@ -0,0 +1,8 @@
+{
+  "policies": [
+    {
+      "title": "Privacy Policy",
+      "body": "Your privacy is important to us"
+    }
+  ]
+}

+ 19 - 0
test/policy_test.rb

@@ -0,0 +1,19 @@
+require 'test_helper'
+
+class PolicyTest < Test::Unit::TestCase
+  def setup
+    super
+    fake 'shop'
+  end
+
+  def test_getting_the_list_of_policies
+    fake 'policies'
+
+    policies = ShopifyAPI::Policy.all
+    assert_equal 1, policies.length
+
+    policy = policies.first
+    assert_equal 'Privacy Policy', policy.title
+    assert_equal 'Your privacy is important to us', policy.body
+  end
+end