Currently, it's necessary to run a script ( ) to create the default tags.
We'd like to move this to an initializer and remove the script. This will also allow us to streamline test setup.
Activity
Show:
ticking instant
April 3, 2023 at 3:41 PM
I’m not sure creating tags in the initializer is a good idea. The code referencing AdminSetting, Locale, and Language is wrapped with 2-3 different rescue blocks to avoid errors when running commands like rake db:drop and rake db:create, and referencing models in initializers breaks entirely on Rails 7.
The issue is fixable by moving all of the code referencing those classes into callbacks, but it might be cleaner to create a db/seeds.rb file to construct everything, and call that whenever necessary (in development or tests).
(Also worth noting: initializers will not be rerun at the start of each test, so whenever truncation is used for database cleaning there will need to be some way to recreate the tags. So moving the tag creation code into an initializer will still require some duplicate setup code for tests.)
tlee911
June 24, 2021 at 2:16 AM
This task (or another related one) should also include doing a pass through the spec files to clean out any let statements for these tags that should be default being created on the fly.
Currently, it's necessary to run a script ( ) to create the default tags.
We'd like to move this to an initializer and remove the script. This will also allow us to streamline test setup.