File tree Expand file tree Collapse file tree 4 files changed +32
-0
lines changed Expand file tree Collapse file tree 4 files changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ * Introduce ` :active_record_fixtures ` lazy load hook.
2
+
3
+ Hooks defined with this name will be run whenever ` TestFixtures ` is included
4
+ in a class.
5
+
6
+ ``` ruby
7
+ ActiveSupport .on_load(:active_record_fixtures ) do
8
+ self .fixture_paths << " test/fixtures"
9
+ end
10
+
11
+ klass = Class .new
12
+ klass.include (ActiveRecord ::TestFixtures )
13
+
14
+ klass.fixture_paths # => ["test/fixtures"]
15
+ ```
16
+
17
+ * Andrew Novoselac *
18
+
1
19
* Introduce ` TestFixtures#fixture_paths` .
2
20
3
21
Multiple fixture paths can now be specified using the ` #fixture_paths` accessor.
Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ def after_teardown # :nodoc:
25
25
class_attribute :pre_loaded_fixtures , default : false
26
26
class_attribute :lock_threads , default : true
27
27
class_attribute :fixture_sets , default : { }
28
+
29
+ ActiveSupport . run_load_hooks ( :active_record_fixtures , self )
28
30
end
29
31
30
32
module ClassMethods
Original file line number Diff line number Diff line change @@ -21,6 +21,17 @@ def test_use_transactional_tests_can_be_overridden
21
21
assert_equal "foobar" , @klass . use_transactional_tests
22
22
end
23
23
24
+ def test_inclusion_runs_active_record_fixtures_load_hook
25
+ ActiveSupport . on_load ( :active_record_fixtures ) do
26
+ self . fixture_paths << "test/fixtures"
27
+ end
28
+ klass = Class . new
29
+
30
+ klass . include ( ActiveRecord ::TestFixtures )
31
+
32
+ assert_includes klass . fixture_paths , "test/fixtures"
33
+ end
34
+
24
35
unless in_memory_db?
25
36
def test_doesnt_rely_on_active_support_test_case_specific_methods
26
37
tmp_dir = Dir . mktmpdir
Original file line number Diff line number Diff line change @@ -1493,6 +1493,7 @@ These are the load hooks you can use in your own code. To hook into the initiali
1493
1493
| ` ActiveJob::Base ` | ` active_job ` |
1494
1494
| ` ActiveJob::TestCase ` | ` active_job_test_case ` |
1495
1495
| ` ActiveRecord::Base ` | ` active_record ` |
1496
+ | ` ActiveRecord::TestFixtures ` | ` active_record_fixtures ` |
1496
1497
| ` ActiveStorage::Attachment ` | ` active_storage_attachment ` |
1497
1498
| ` ActiveStorage::VariantRecord ` | ` active_storage_variant_record ` |
1498
1499
| ` ActiveStorage::Blob ` | ` active_storage_blob ` |
You can’t perform that action at this time.
0 commit comments