Created
July 23, 2020 21:51
-
-
Save philippegirard/7c043eae65afde7133a809af6f950f69 to your computer and use it in GitHub Desktop.
Omniauth integration testing
This file contains hidden or 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
ENV['RAILS_ENV'] ||= 'test' | |
require_relative '../config/environment' | |
require 'rails/test_help' | |
OmniAuth.config.test_mode = true | |
class ActiveSupport::TestCase | |
# ...some code here | |
def login_shop(shop) | |
# remove this line for omniAuth logs | |
OmniAuth.config.logger = Rails.logger | |
OmniAuth.config.test_mode = true | |
OmniAuth.config.add_mock(:shopify, | |
provider: 'shopify', | |
uid: shop.shopify_domain, | |
credentials: {token: shop.shopify_token} | |
) | |
Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[:shopify] | |
get "/auth/shopify" | |
follow_redirect! | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment