diff options
author | José Valim <jose.valim@gmail.com> | 2009-07-01 19:02:51 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-07-02 10:27:40 +0200 |
commit | 86ff07410145430d08e97a8296486c4cd4304cde (patch) | |
tree | c8a648363bf29664c0c076b944d3f6145f4d4ffb /railties/lib/generators/test_unit/scaffold/templates/functional_test.rb | |
parent | 80cd16372ce1776e5d6af87b2dc7be8205fa1513 (diff) | |
download | rails-86ff07410145430d08e97a8296486c4cd4304cde.tar.gz rails-86ff07410145430d08e97a8296486c4cd4304cde.tar.bz2 rails-86ff07410145430d08e97a8296486c4cd4304cde.zip |
Added test unit files for scaffold_controller.
Diffstat (limited to 'railties/lib/generators/test_unit/scaffold/templates/functional_test.rb')
-rw-r--r-- | railties/lib/generators/test_unit/scaffold/templates/functional_test.rb | 45 |
1 files changed, 45 insertions, 0 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 new file mode 100644 index 0000000000..cd2fc578bf --- /dev/null +++ b/railties/lib/generators/test_unit/scaffold/templates/functional_test.rb @@ -0,0 +1,45 @@ +require 'test_helper' + +class <%= controller_class_name %>ControllerTest < ActionController::TestCase + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:<%= table_name %>) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create <%= file_name %>" do + assert_difference('<%= class_name %>.count') do + post :create, :<%= file_name %> => { } + 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 + assert_response :success + end + + test "should get edit" do + get :edit, :id => <%= table_name %>(:one).to_param + assert_response :success + end + + test "should update <%= file_name %>" do + 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).to_param + end + + assert_redirected_to <%= table_name %>_path + end +end |