Browse Source

Merge pull request #67 from Shopify/bugfix/fix_tests_since_3.0.3

include_root_in_json for all but ActiveResource 3.1
Neil Costford 11 years ago
parent
commit
5c36ccbf34
4 changed files with 15 additions and 2 deletions
  1. 8 0
      CHANGELOG
  2. 2 0
      lib/shopify_api/json_format.rb
  3. 4 1
      lib/shopify_api/resources/base.rb
  4. 1 1
      lib/shopify_api/version.rb

+ 8 - 0
CHANGELOG

@@ -1,3 +1,11 @@
+== Version 3.1.1
+
+* Includes port in domain URI (when other than http/80 or https/443)
+* Adds access to CustomerSavedSearch
+* Adds resources: Order::DefaultAddress, Client::ClientDetails, Announcement
+* Allows access to Articles without a blog_id
+* Qualifies and scopes encode/decode changes in ActiveResource 3.0, 3.1, 3.2, 4.0
+
 == Version 3.1.0
 
 * Expose the `order` action in SmartCollection for general use

+ 2 - 0
lib/shopify_api/json_format.rb

@@ -1,4 +1,6 @@
 module ActiveResource
+
+  # ActiveResource 3.1 removes root on decoding, so this patch is only needed in 3.0
   if ActiveResource::VERSION::MAJOR == 3 && ActiveResource::VERSION::MINOR == 0
     module Formats
       module JsonFormat

+ 4 - 1
lib/shopify_api/resources/base.rb

@@ -3,12 +3,15 @@ require 'shopify_api/version'
 module ShopifyAPI
   class Base < ActiveResource::Base
     extend Countable
-    self.include_root_in_json = false
+    self.include_root_in_json = true
     self.headers['User-Agent'] = ["ShopifyAPI/#{ShopifyAPI::VERSION}",
                                   "ActiveResource/#{ActiveResource::VERSION::STRING}",
                                   "Ruby/#{RUBY_VERSION}"].join(' ')
 
+    # this patch only needed until 3.1 because ActiveResouce 3.2 passes :root to as_json (and encode regardless of include_root_in_json)
     if ActiveResource::VERSION::MAJOR == 3 && ActiveResource::VERSION::MINOR <= 1
+      self.include_root_in_json = false
+
       def encode(options = {})
         same = dup
         same.attributes = {self.class.element_name => same.attributes} if self.class.format.extension == 'json'

+ 1 - 1
lib/shopify_api/version.rb

@@ -1,3 +1,3 @@
 module ShopifyAPI
-  VERSION = "3.1.0"
+  VERSION = "3.1.1"
 end