diff options
author | Roque Pinel <repinel@gmail.com> | 2015-06-15 23:16:39 -0400 |
---|---|---|
committer | Roque Pinel <repinel@gmail.com> | 2015-09-11 14:29:06 -0400 |
commit | 2acec4657752d441ab87b9f5862d7918843d6409 (patch) | |
tree | 8c838ca318721dd615165b498e1bd74bd17cc1cf /activerecord/test/cases/fixture_set | |
parent | bbf0d35bf6148752911c1da4b7449450faea8755 (diff) | |
download | rails-2acec4657752d441ab87b9f5862d7918843d6409.tar.gz rails-2acec4657752d441ab87b9f5862d7918843d6409.tar.bz2 rails-2acec4657752d441ab87b9f5862d7918843d6409.zip |
Allow fixtures YAML files to set the model class in the file itself
Currently, `set_fixture_class` is only available using the
`TestFixtures` concern and it is ignored for `rake db:fixtures:load`.
Using the correct model class, it is possible for the fixture load
to also load the associations from the YAML files (e.g., `:belongs_to`
and `:has_many`).
Diffstat (limited to 'activerecord/test/cases/fixture_set')
-rw-r--r-- | activerecord/test/cases/fixture_set/file_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/fixture_set/file_test.rb b/activerecord/test/cases/fixture_set/file_test.rb index 92efa8aca7..79951c91c9 100644 --- a/activerecord/test/cases/fixture_set/file_test.rb +++ b/activerecord/test/cases/fixture_set/file_test.rb @@ -123,6 +123,16 @@ END end end + def test_fixture_model_class_and_rows + File.open(::File.join(FIXTURES_ROOT, 'other_posts.yml')) do |fh| + assert_equal 'Post', fh.model_class + + fixture_names = [] + fh.each { |fixture_name, _| fixture_names << fixture_name } + assert_equal ['second_welcome'], fixture_names + end + end + private def tmp_yaml(name, contents) t = Tempfile.new name |