Skip to content

Commit

Permalink
Changed scaffold generated controller tests to use #to_param.
Browse files Browse the repository at this point in the history
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
nakajima authored and NZKoz committed Feb 13, 2009
1 parent 11b4a6d commit 0c95644
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -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
Expand Down

0 comments on commit 0c95644

Please sign in to comment.