0

How do I configure my Rails test environment so I can both

  1. Run integration tests on my controllers (which require forgery protection turned off), and
  2. Run system tests that require forgery protection turned on?

(The system tests need forgery protection turned on because my application contains JavaScript that requests additional data as the user navigates the page.)

Do I need to create two separate environments? Or is there a way for test.rb to recognize which type of tests I'm about to run and set config.action_controller.allow_forgery_protection accordingly?

Zack
  • 6,232
  • 8
  • 38
  • 68
  • 1
    It was already answered here: https://stackoverflow.com/questions/5917939/override-action-controller-allow-forgery-protection-for-specific-integration-tes – Kamil Gwóźdź Feb 13 '22 at 12:00
  • Thanks for the pointer. That's a different question, but the answer is the same. In my case, I added the `setup` method to `ApplicationSystemTestCase` (the parent class of the system tests). – Zack Feb 13 '22 at 19:12

0 Answers0