diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 4a2cc3cff9..8aecfe1cbf 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Generated scaffold functional tests use assert_difference. #8421 [norbert] + * Update to Prototype 1.5.1. [Sam Stephenson] * Update to script.aculo.us 1.7.1_beta3. [Thomas Fuchs] diff --git a/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb b/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb index 0c68fd3122..7619b04dc3 100644 --- a/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +++ b/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb @@ -25,9 +25,9 @@ class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase end def test_should_create_<%= file_name %> - old_count = <%= class_name %>.count - post :create, :<%= file_name %> => { } - assert_equal old_count+1, <%= class_name %>.count + assert_difference('<%= class_name %>.count') do + post :create, :<%= file_name %> => { } + end assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>)) end @@ -48,9 +48,9 @@ class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase end def test_should_destroy_<%= file_name %> - old_count = <%= class_name %>.count - delete :destroy, :id => 1 - assert_equal old_count-1, <%= class_name %>.count + assert_difference('<%= class_name %>.count', -1) do + delete :destroy, :id => 1 + end assert_redirected_to <%= table_name %>_path end