Fix for `TypeError: can't convert Hash into Integer` when calling `Product.count` with latest activeresource
@@ -1,7 +1,14 @@
module ShopifyAPI
module Countable
def count(options = {})
- Integer(get(:count, options))
+ data = get(:count, options)
+
+ count = case data
+ when Hash then data["count"]
+ else data
+ end
+ Integer(count)
end
@@ -0,0 +1,12 @@
+require 'test_helper'
+class CountableTest < Test::Unit::TestCase
+ def setup
+ fake "products/count", :body => '{"count": 16}'
+ def test_count_products
+ count = ShopifyAPI::Product.count
+ assert_equal 16, count
+end