Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from redronin/oauth
replaces the legacy auth code with Oauth2 functionality
- Loading branch information
Showing
4 changed files
with
104 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
require 'test_helper' | ||
|
||
|
||
class BaseTest < Test::Unit::TestCase | ||
|
||
def setup | ||
@session1 = ShopifyAPI::Session.new('shop1.myshopify.com', 'token1') | ||
@session2 = ShopifyAPI::Session.new('shop2.myshopify.com', 'token2') | ||
end | ||
|
||
test '#activate_session should set site and headers for given session' do | ||
ShopifyAPI::Base.activate_session @session1 | ||
|
||
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.clear_session | ||
|
||
assert_nil ActiveResource::Base.site | ||
assert_nil ShopifyAPI::Base.site | ||
assert_nil ShopifyAPI::Shop.site | ||
|
||
assert_nil ActiveResource::Base.headers['X-Shopify-Access-Token'] | ||
assert_nil ShopifyAPI::Base.headers['X-Shopify-Access-Token'] | ||
assert_nil ShopifyAPI::Shop.headers['X-Shopify-Access-Token'] | ||
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 @session2 | ||
|
||
assert_nil ActiveResource::Base.site | ||
assert_equal 'https://shop2.myshopify.com/admin', ShopifyAPI::Base.site.to_s | ||
assert_equal 'https://shop2.myshopify.com/admin', ShopifyAPI::Shop.site.to_s | ||
|
||
assert_nil ActiveResource::Base.headers['X-Shopify-Access-Token'] | ||
assert_equal 'token2', ShopifyAPI::Base.headers['X-Shopify-Access-Token'] | ||
assert_equal 'token2', ShopifyAPI::Shop.headers['X-Shopify-Access-Token'] | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters