|
@@ -14,14 +14,14 @@ class BaseTest < Test::Unit::TestCase
|
|
|
assert_nil ActiveResource::Base.site
|
|
|
assert_equal 'https://shop1.myshopify.com/admin', ShopifyAPI::Base.site.to_s
|
|
|
assert_equal 'https://shop1.myshopify.com/admin', ShopifyAPI::Shop.site.to_s
|
|
|
-
|
|
|
+
|
|
|
assert_nil ActiveResource::Base.headers['X-Shopify-Access-Token']
|
|
|
assert_equal 'token1', ShopifyAPI::Base.headers['X-Shopify-Access-Token']
|
|
|
assert_equal 'token1', ShopifyAPI::Shop.headers['X-Shopify-Access-Token']
|
|
|
end
|
|
|
|
|
|
test '#clear_session should clear site and headers from Base' do
|
|
|
- ShopifyAPI::Base.activate_session @session1
|
|
|
+ ShopifyAPI::Base.activate_session @session1
|
|
|
ShopifyAPI::Base.clear_session
|
|
|
|
|
|
assert_nil ActiveResource::Base.site
|
|
@@ -34,8 +34,8 @@ class BaseTest < Test::Unit::TestCase
|
|
|
end
|
|
|
|
|
|
test '#activate_session with one session, then clearing and activating with another session should send request to correct shop' do
|
|
|
- ShopifyAPI::Base.activate_session @session1
|
|
|
- ShopifyAPI::Base.clear_session
|
|
|
+ ShopifyAPI::Base.activate_session @session1
|
|
|
+ ShopifyAPI::Base.clear_session
|
|
|
ShopifyAPI::Base.activate_session @session2
|
|
|
|
|
|
assert_nil ActiveResource::Base.site
|
|
@@ -54,4 +54,27 @@ class BaseTest < Test::Unit::TestCase
|
|
|
ShopifyAPI::Base.delete "1"
|
|
|
end
|
|
|
|
|
|
+ test "#headers includes the User-Agent" do
|
|
|
+ assert_includes ShopifyAPI::Base.headers.keys, 'User-Agent'
|
|
|
+ thread = Thread.new do
|
|
|
+ assert_includes ShopifyAPI::Base.headers.keys, 'User-Agent'
|
|
|
+ end
|
|
|
+ thread.join
|
|
|
+ end
|
|
|
+
|
|
|
+ if ActiveResource::VERSION::MAJOR >= 4
|
|
|
+ test "#headers is threadsafe" do
|
|
|
+ thread1 = Thread.new do
|
|
|
+ ShopifyAPI::Base.headers['X-Custom'] = "My header value"
|
|
|
+ assert_includes ShopifyAPI::Base.headers.keys, 'X-Custom'
|
|
|
+ end
|
|
|
+ thread1.join
|
|
|
+ thread2 = Thread.new do
|
|
|
+ assert_not_includes ShopifyAPI::Base.headers.keys, 'X-Custom'
|
|
|
+ end
|
|
|
+ thread2.join
|
|
|
+
|
|
|
+ assert_nil ShopifyAPI::Base.headers['X-Custom']
|
|
|
+ end
|
|
|
+ end
|
|
|
end
|