diff --git a/railties/CHANGELOG b/railties/CHANGELOG index ced871f3b1..ddb5fcf8ba 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added demonstration of fixture use to the test case generated by the model generator [DHH] + * If specified, pass PostgreSQL client character encoding to createdb. #2703 [Kazuhiko ] * Catch CGI multipart parse errors. Wrap dispatcher internals in a failsafe response handler. [Jeremy Kemper] diff --git a/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml b/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml index d29fcff2ff..8794d28ae4 100644 --- a/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml +++ b/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml @@ -1,5 +1,5 @@ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html -first_<%= singular_name %>: +first: id: 1 -another_<%= singular_name %>: +another: id: 2 diff --git a/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb b/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb index e8714b589a..852b5d2529 100644 --- a/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb +++ b/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb @@ -3,12 +3,8 @@ require File.dirname(__FILE__) + '/../test_helper' class <%= class_name %>Test < Test::Unit::TestCase fixtures :<%= table_name %> - def setup - @<%= singular_name %> = <%= class_name %>.find(1) - end - # Replace this with your real tests. def test_truth - assert_kind_of <%= class_name %>, @<%= singular_name %> + assert_kind_of <%= class_name %>, <%= table_name %>(:first) end end