Permalink
Browse files

Changed scaffold generated controller tests to use #to_param.

Before, the generated controller tests were calling #id, which
can change over time, making for brittle tests.

Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1913 state:committed]
  • Loading branch information...
1 parent 11b4a6d commit 0c956443964a20cbcc122e2d8c429b0cbb121828 @nakajima nakajima committed with NZKoz Feb 8, 2009
@@ -21,23 +21,23 @@ class <%= controller_class_name %>ControllerTest < ActionController::TestCase
end
test "should show <%= file_name %>" do
- get :show, :id => <%= table_name %>(:one).id
+ get :show, :id => <%= table_name %>(:one).to_param
assert_response :success
end
test "should get edit" do
- get :edit, :id => <%= table_name %>(:one).id
+ get :edit, :id => <%= table_name %>(:one).to_param
assert_response :success
end
test "should update <%= file_name %>" do
- put :update, :id => <%= table_name %>(:one).id, :<%= file_name %> => { }
+ put :update, :id => <%= table_name %>(:one).to_param, :<%= file_name %> => { }
assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
end
test "should destroy <%= file_name %>" do
assert_difference('<%= class_name %>.count', -1) do
- delete :destroy, :id => <%= table_name %>(:one).id
+ delete :destroy, :id => <%= table_name %>(:one).to_param
end
assert_redirected_to <%= table_name %>_path

0 comments on commit 0c95644

Please sign in to comment.