Browse Source

Merge pull request #177 from anark/master

Allow options to be passed to shop fetching
Christopher Saunders 10 years ago
parent
commit
390cfbedc2
2 changed files with 11 additions and 2 deletions
  1. 2 2
      lib/shopify_api/resources/shop.rb
  2. 9 0
      test/shop_test.rb

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

@@ -2,8 +2,8 @@ module ShopifyAPI
   # Shop object. Use Shop.current to receive 
   # the shop.
   class Shop < Base
-    def self.current
-      find(:one, from: "/admin/shop.#{format.extension}")
+    def self.current(options={})
+      find(:one, options.merge({from: "/admin/shop.#{format.extension}"}))
     end
 
     def metafields

+ 9 - 0
test/shop_test.rb

@@ -16,6 +16,15 @@ class ShopTest < Test::Unit::TestCase
     assert_nil @shop.tax_shipping
   end
 
+  def test_current_with_options_should_return_current_shop
+    fake "shop.json?fields%5B%5D=name&fields%5B%5D=myshopify_domain", :extension => false, :method => :get, :status => 201, :body => load_fixture('shop')
+
+    @shop = ShopifyAPI::Shop.current(params: { fields: [:name, :myshopify_domain]})
+    assert @shop.is_a?(ShopifyAPI::Shop)
+    assert_equal "Apple Computers", @shop.name
+    assert_equal "apple.myshopify.com", @shop.myshopify_domain
+  end
+
   def test_get_metafields_for_shop
     fake "metafields"