From a93f385c2b675e003afb98a57a9bd0f6377667cc Mon Sep 17 00:00:00 2001 From: schneems Date: Mon, 2 Jun 2014 10:38:03 -0500 Subject: [ci skip] add fixture docs link to guides The fixtures API docs are really comprehensive. We should either be driving people there, or perhaps making fixtures its own guide. --- guides/source/testing.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/testing.md b/guides/source/testing.md index bac4b63c75..9468f03442 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -49,7 +49,9 @@ The `test_helper.rb` file holds the default configuration for your tests. ### The Low-Down on Fixtures -For good tests, you'll need to give some thought to setting up test data. In Rails, you can handle this by defining and customizing fixtures. +For good tests, you'll need to give some thought to setting up test data. +In Rails, you can handle this by defining and customizing fixtures. +You can find comprehensive documentation in the [fixture api documentation](http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html). #### What Are Fixtures? -- cgit v1.2.3 From 071373857dddeefcb7a36f8838c03c5e88dd6e20 Mon Sep 17 00:00:00 2001 From: schneems Date: Mon, 2 Jun 2014 10:42:48 -0500 Subject: [ci skip] explain association behavior. When you manually specify `id:` attribute in a fixture Rails' built in association assignment feature will no longer work. http://stackoverflow.com/questions/23985675/incorrect-association-in-fixtures This commit raises awareness of this behavior and encourages developers to look directly at the fixture documentation. --- guides/source/testing.md | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'guides') diff --git a/guides/source/testing.md b/guides/source/testing.md index 9468f03442..c01b2e575a 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -96,6 +96,12 @@ one: category: about ``` +Note: For associations to reference one another by name, you cannot specify the `id:` + attribute on the fixtures. Rails will auto assign a primary key to be consistent between + runs. If you manually specify an `id:` attribute, this behavior will not work. For more + information on this assocation behavior please read the + [fixture api documentation](http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html). + #### ERB'in It Up ERB allows you to embed Ruby code within templates. The YAML fixture format is pre-processed with ERB when Rails loads fixtures. This allows you to use Ruby to help you generate some sample data. For example, the following code generates a thousand users: -- cgit v1.2.3