Prechádzať zdrojové kódy

Merge pull request #563 from JohnnyKei/fix-base

fix set base api version
Dave Newton 6 rokov pred
rodič
commit
18168156ce
2 zmenil súbory, kde vykonal 7 pridanie a 2 odobranie
  1. 2 2
      lib/shopify_api/resources/base.rb
  2. 5 0
      test/base_test.rb

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

@@ -76,8 +76,8 @@ module ShopifyAPI
         end
       end
 
-      def api_version=(value)
-        self._api_version = value
+      def api_version=(version)
+        self._api_version = version.nil? ? nil : ApiVersion.coerce_to_version(version)
       end
 
       def prefix(options = {})

+ 5 - 0
test/base_test.rb

@@ -157,6 +157,11 @@ class BaseTest < Test::Unit::TestCase
     assert_equal 2, ShopifyAPI::Shop.current.id
   end
 
+  test "#api_version should set ApiVersion" do
+    ShopifyAPI::Base.api_version = '2019-04'
+    assert_equal '2019-04', ShopifyAPI::Base.api_version.to_s
+  end
+
   def clear_header(header)
     [ActiveResource::Base, ShopifyAPI::Base, ShopifyAPI::Product].each do |klass|
       klass.headers.delete(header)