Ver Fonte

Merge pull request #307 from orenmazor/dont_be_basic

Unexpected Auth headers is so Basic
Kevin Hughes há 8 anos atrás
pai
commit
59db7d3519
2 ficheiros alterados com 15 adições e 0 exclusões
  1. 2 0
      lib/shopify_api/resources/base.rb
  2. 13 0
      test/base_test.rb

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

@@ -58,6 +58,8 @@ module ShopifyAPI
 
       def clear_session
         self.site = nil
+        self.password = nil
+        self.user = nil
         self.headers.delete('X-Shopify-Access-Token')
       end
 

+ 13 - 0
test/base_test.rb

@@ -24,6 +24,19 @@ class BaseTest < Test::Unit::TestCase
     assert_equal 'token1', ShopifyAPI::Shop.headers['X-Shopify-Access-Token']
   end
 
+  test '#clear_session should clear base site settings from Base' do
+    ShopifyAPI::Base.site = "https://foo:bar@www.zombo.com"
+
+    assert_equal "foo", ShopifyAPI::Base.user
+    assert_equal "bar", ShopifyAPI::Base.password
+
+    ShopifyAPI::Base.clear_session
+
+    assert_equal nil, ShopifyAPI::Base.user
+    assert_equal nil, ShopifyAPI::Base.password
+    assert_equal nil, ShopifyAPI::Base.site
+  end
+
   test '#clear_session should clear site and headers from Base' do
     ShopifyAPI::Base.activate_session @session1
     ShopifyAPI::Base.clear_session