Testing Controllers Of A Rails Shopify App
I have a Rails app created through shopify_app gem and I'm trying to test my controllers using rspec. Since all my controllers inherit from
ShopifyApp::AuthenticatedController, all testing requests get blocked by authentication, so I can't test my controllers.
I've seen a few suggestions of bypassing the authentication by stubbing the session like so:
session[:shopify] = ShopifyAPI::Session.new(domain)
But that still doesn't work for me. The requests seems to get redirected (response code 302).
I'm sure a lot of people stumbled upon this. But after a day of googling I couldn't find a working solution. Any help is appreciated!
The session object needs to be stubbed from @request, like so:
@request.session[:shopify] = shop.id @request.session[:shopify_domain] = shop.shopify_domain
I received a detailed answer in this post on the Shopify forum.
- → Trigger a click with jQuery using link_to of rails 4
- → Adding html data attribute to simple_forms input
- → How to remove parameters from the root URL if it does I18n
- → passing parameters to rails back end from an ajax call
- → Blocking ?page= in robots.txt
- → react js and rails Updating state on a component with active record relationship
- → State not passed into prop
- → Cannot read property 'modalIsOpen' of undefined
- → Objects not valid issue
- → How to map API params to model
- → Consuming webhooks shopify-api
- → How to add ScriptTag on shopify_api gem?