aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators/resource_generator_test.rb
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2018-03-20 13:47:34 -0400
committereileencodes <eileencodes@gmail.com>2018-03-21 16:54:24 -0400
commit4e663c1e8d1e643783f157f904b5276e62f65589 (patch)
treec258273b4cbf8451f32d13692f8a0ffa183b6cdc /railties/test/generators/resource_generator_test.rb
parentbb9e5540c8fd3f48d461362c652cb86c17d9c5f3 (diff)
downloadrails-4e663c1e8d1e643783f157f904b5276e62f65589.tar.gz
rails-4e663c1e8d1e643783f157f904b5276e62f65589.tar.bz2
rails-4e663c1e8d1e643783f157f904b5276e62f65589.zip
Refactor configs_for and friends
Moves the configs_for and DatabaseConfig struct into it's own file. I was considering doing this in a future refactoring but our set up forced me to move it now. You see there are `mattr_accessor`'s on the Core module that have default settings. For example the `schema_format` defaults to Ruby. So if I call `configs_for` or any methods in the Core module it will reset the `schema_format` to `:ruby`. By moving it to it's own class we can keep the logic contained and avoid this unfortunate issue. The second change here does a double loop over the yaml files. Bear with me... Our tests dictate that we need to load an environment before our rake tasks because we could have something in an environment that the database.yml depends on. There are side-effects to this and I think there's a deeper bug that needs to be fixed but that's for another issue. The gist of the problem is when I was creating the dynamic rake tasks if the yaml that that rake task is calling evaluates code (like erb) that calls the environment configs the code will blow up because the environment is not loaded yet. To avoid this issue we added a new method that simply loads the yaml and does not evaluate the erb or anything in it. We then use that yaml to create the task name. Inside the task name we can then call `load_config` and load the real config to actually call the code internal to the task. I admit, this is gross, but refactoring can't all be pretty all the time and I'm working hard with `@tenderlove` to refactor much more of this code to get to a better place re connection management and rake tasks.
Diffstat (limited to 'railties/test/generators/resource_generator_test.rb')
0 files changed, 0 insertions, 0 deletions