DEV: Stubbing "Rails.env.production?" introduces a lot of flakiness. (PR #13188)

We need to be careful when stubbing this method. SessionController#become won’t be defined if production is set to true, so if these tests run first, calling #sign_in will fail for other tests.

Calling sign_in before stubbing guarantees the method is defined because the check happens when the class is loaded.

GitHub