From 2acec4657752d441ab87b9f5862d7918843d6409 Mon Sep 17 00:00:00 2001 From: Roque Pinel Date: Mon, 15 Jun 2015 23:16:39 -0400 Subject: 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`). --- activerecord/test/fixtures/.DS_Store | Bin 0 -> 6148 bytes activerecord/test/fixtures/bad_posts.yml | 10 ++++++++++ activerecord/test/fixtures/other_comments.yml | 7 +++++++ activerecord/test/fixtures/other_posts.yml | 8 ++++++++ 4 files changed, 25 insertions(+) create mode 100644 activerecord/test/fixtures/.DS_Store create mode 100644 activerecord/test/fixtures/bad_posts.yml create mode 100644 activerecord/test/fixtures/other_comments.yml create mode 100644 activerecord/test/fixtures/other_posts.yml (limited to 'activerecord/test/fixtures') diff --git a/activerecord/test/fixtures/.DS_Store b/activerecord/test/fixtures/.DS_Store new file mode 100644 index 0000000000..5008ddfcf5 Binary files /dev/null and b/activerecord/test/fixtures/.DS_Store differ diff --git a/activerecord/test/fixtures/bad_posts.yml b/activerecord/test/fixtures/bad_posts.yml new file mode 100644 index 0000000000..d31ed3d5c6 --- /dev/null +++ b/activerecord/test/fixtures/bad_posts.yml @@ -0,0 +1,10 @@ +# Please do not use this fixture without `set_fixture_class` as Post + +_fixture: + model_class: BadPostModel + +bad_welcome: + author_id: 1 + title: Welcome to the another weblog + body: It's really nice today + type: Post diff --git a/activerecord/test/fixtures/other_comments.yml b/activerecord/test/fixtures/other_comments.yml new file mode 100644 index 0000000000..f10a4f4829 --- /dev/null +++ b/activerecord/test/fixtures/other_comments.yml @@ -0,0 +1,7 @@ +_fixture: + model_class: Comment + +second_greetings: + post: second_welcome + body: Thank you for the second welcome + type: Comment diff --git a/activerecord/test/fixtures/other_posts.yml b/activerecord/test/fixtures/other_posts.yml new file mode 100644 index 0000000000..9675ed2a76 --- /dev/null +++ b/activerecord/test/fixtures/other_posts.yml @@ -0,0 +1,8 @@ +_fixture: + model_class: Post + +second_welcome: + author_id: 1 + title: Welcome to the another weblog + body: It's really nice today + type: Post -- cgit v1.2.3