aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-05-22 09:41:28 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-05-22 09:41:28 +0000
commit43cd97e7fa7043246da7129520ba8b69fbaea82e (patch)
tree60e7a023bdee0d22e7c1b1a790ec4e703b7f83e6 /railties
parentdef8f101b86fbafb2d70316f9218bba9cb276754 (diff)
downloadrails-43cd97e7fa7043246da7129520ba8b69fbaea82e.tar.gz
rails-43cd97e7fa7043246da7129520ba8b69fbaea82e.tar.bz2
rails-43cd97e7fa7043246da7129520ba8b69fbaea82e.zip
Generated scaffold functional tests use assert_difference. Closes #8421.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6808 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties')
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb12
2 files changed, 8 insertions, 6 deletions
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