-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run a load hook when TestFixtures is included #47690
Run a load hook when TestFixtures is included #47690
Conversation
8f7356e
to
6f8e088
Compare
@@ -25,6 +25,8 @@ def after_teardown # :nodoc: | |||
class_attribute :pre_loaded_fixtures, default: false | |||
class_attribute :lock_threads, default: true | |||
class_attribute :fixture_sets, default: {} | |||
|
|||
ActiveSupport.run_load_hooks(:active_record_fixtures, self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to document this new hook in engines.md
rails/guides/source/engines.md
Line 1463 in 74554cd
### Available Load Hooks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it. Though.. the column header is "Class" and TestFixtures
is is a mixin.. does it warrant it's own section or explanation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried something more descriptive, let me know what you think.
6f8e088
to
f0da985
Compare
b6bfbb0
to
982cd23
Compare
I'm a little late since #47675 was merged already, but would it make sense to utilize rails/railties/lib/rails/engine.rb Lines 603 to 615 in f91bd40
|
@skipkayhil Thanks for pointing this out, I wasn't familiar with this. I don't think we need all the functionality provided by Edit: hmm on second thought, I think we need |
We will probably end up there with the feature I'm working on, but right now I don't think we need to use engine paths just yet. |
guides/source/engines.md
Outdated
@@ -1462,7 +1462,11 @@ end | |||
|
|||
### Available Load Hooks | |||
|
|||
These are the load hooks you can use in your own code. To hook into the initialization process of one of the following classes use the available hook. | |||
These are the load hooks you can use in your own code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just merge the two and change classes
to constants. i18n
isn't a class and we put in the same table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
982cd23
to
49283ad
Compare
Motivation / Background
This Pull Request has been created as a follow up to #47675. In the example I gave in that PR, I showed that you can define an
active_model_test_case
load hook and shovel onto thefixture_paths
. However, I now realize this won't actually work, becauseTestFixtures
itself is included inActiveSupport::TestCase
from a load hook. Since there is no way to control the order the hooks are run in, thefixture_paths
method may be undefined at that the time the hook is run.Detail
This Pull Request adds an
:active_record_fixtures
load hook. This load hook is run every timeTestFixtures
is included. So the fixture paths can be added to from this hook. Eg:Additional information
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]