Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent Unable to autoload constant error in tests
When running these tests, under certain conditions, we get a warning followed by an error: ``` activesupport-6.1.7.7/lib/active_support/dependencies.rb:502: warning: already initialized constant ActiveStorage::Representations activesupport-6.1.7.7/lib/active_support/dependencies.rb:502: warning: previous definition of Representations was here Failure/Error: raise LoadError, "Unable to autoload constant '#{qualified_name}', expected #{file_path} to define it" LoadError: Unable to autoload constant ActiveStorage::Representations::RedirectController, expected activestorage-6.1.7.7/app/controllers/active_storage/representations/redirect_controller.rb to define it ``` The error seems to take place when we request a page in a test that loads two (or more) ActiveStorage images if ActiveStorage hasn't loaded yet, although it's a flaky error and so the test doesn't always behave like this. We've tested that switching to zeitwerk solves the issue but, since we aren't switching to zeitwerk in version 2.1.1 and we'd like this version to run all tests correctly, for now we're changing the tests so they don't load two records with images. On of these tests ("Polls Index Polls can be listed") fails on my machine when run individually. I haven't been able to consistently reproduce the other ones.
- Loading branch information