Skip to content

Commit

Permalink
Raise exception when shop domain not found
Browse files Browse the repository at this point in the history
  • Loading branch information
Hammadk committed Apr 10, 2017
1 parent fc4c475 commit d8cd1dc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/shopify_app/login_protection.rb
Expand Up @@ -2,6 +2,8 @@ module ShopifyApp
module LoginProtection
extend ActiveSupport::Concern

class ShopifyDomainNotFound < StandardError; end

included do
rescue_from ActiveResource::UnauthorizedAccess, :with => :close_session
end
Expand Down Expand Up @@ -98,7 +100,10 @@ def redirection_javascript(url)
end

def current_shopify_domain
sanitized_shop_name || session[:shopify_domain]
shopify_domain = sanitized_shop_name || session[:shopify_domain]
return shopify_domain if shopify_domain.present?

raise ShopifyDomainNotFound
end

def sanitized_shop_name
Expand Down
9 changes: 9 additions & 0 deletions test/shopify_app/login_protection_test.rb
Expand Up @@ -118,6 +118,15 @@ class LoginProtectionTest < ActionController::TestCase
end
end

test '#fullpage_redirect_to raises an exception when no Shopify domains are available' do
with_application_test_routes do
session[:shopify_domain] = nil
assert_raise ShopifyApp::LoginProtection::ShopifyDomainNotFound do
get :redirect
end
end
end

private

def assert_fullpage_redirected(shop_domain, response)
Expand Down

0 comments on commit d8cd1dc

Please sign in to comment.