diff options
author | José Valim <jose.valim@gmail.com> | 2010-03-16 16:53:54 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-03-16 16:53:54 +0100 |
commit | 0db68fd1408e52b1edc62b18756ba2662f9b5b3c (patch) | |
tree | ee12b68b52f584f611ceded7bc4b528cd9b1fe09 /railties/lib/generators | |
parent | e13c179499f227071cbe829221877e1c0d03c0b1 (diff) | |
download | rails-0db68fd1408e52b1edc62b18756ba2662f9b5b3c.tar.gz rails-0db68fd1408e52b1edc62b18756ba2662f9b5b3c.tar.bz2 rails-0db68fd1408e52b1edc62b18756ba2662f9b5b3c.zip |
Change functional tests to make use of a setup block.
Diffstat (limited to 'railties/lib/generators')
-rw-r--r-- | railties/lib/generators/test_unit/scaffold/templates/functional_test.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/railties/lib/generators/test_unit/scaffold/templates/functional_test.rb b/railties/lib/generators/test_unit/scaffold/templates/functional_test.rb index 9380aa49b6..4f8ddbffcf 100644 --- a/railties/lib/generators/test_unit/scaffold/templates/functional_test.rb +++ b/railties/lib/generators/test_unit/scaffold/templates/functional_test.rb @@ -1,6 +1,10 @@ require 'test_helper' class <%= controller_class_name %>ControllerTest < ActionController::TestCase + setup do + @<%= file_name %> = <%= table_name %>(:one) + end + <% unless options[:singleton] -%> test "should get index" do get :index @@ -16,30 +20,30 @@ class <%= controller_class_name %>ControllerTest < ActionController::TestCase test "should create <%= file_name %>" do assert_difference('<%= class_name %>.count') do - post :create, :<%= file_name %> => <%= table_name %>(:one).attributes + post :create, :<%= file_name %> => @<%= file_name %>.attributes end assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>)) end test "should show <%= file_name %>" do - get :show, :id => <%= table_name %>(:one).to_param + get :show, :id => @<%= file_name %>.to_param assert_response :success end test "should get edit" do - get :edit, :id => <%= table_name %>(:one).to_param + get :edit, :id => @<%= file_name %>.to_param assert_response :success end test "should update <%= file_name %>" do - put :update, :id => <%= table_name %>(:one).to_param, :<%= file_name %> => <%= table_name %>(:one).attributes + put :update, :id => @<%= file_name %>.to_param, :<%= file_name %> => @<%= file_name %>.attributes 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).to_param + delete :destroy, :id => @<%= file_name %>.to_param end assert_redirected_to <%= table_name %>_path |