Skip to content

Instantly share code, notes, and snippets.

@philippegirard
Created July 23, 2020 21:51
Show Gist options
  • Save philippegirard/7c043eae65afde7133a809af6f950f69 to your computer and use it in GitHub Desktop.
Save philippegirard/7c043eae65afde7133a809af6f950f69 to your computer and use it in GitHub Desktop.
Omniauth integration testing
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