diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-06-12 05:33:23 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-06-12 05:33:23 +0000 |
commit | 3cb26e9cb3c1f3a069e7654988c650ca12322ede (patch) | |
tree | 1f60bc9bfb288f8fcb4c9576cdddf7b6708d2051 /railties/lib | |
parent | dedb9c8483fc916bb5fd40d7e8a35af5f8e7a90b (diff) | |
download | rails-3cb26e9cb3c1f3a069e7654988c650ca12322ede.tar.gz rails-3cb26e9cb3c1f3a069e7654988c650ca12322ede.tar.bz2 rails-3cb26e9cb3c1f3a069e7654988c650ca12322ede.zip |
r2495@sedna: jeremy | 2005-05-27 22:07:18 -0700
Branch to have scaffold use new render methods
r2496@sedna: jeremy | 2005-05-28 10:50:51 -0700
axe unused process_request method
r2497@sedna: jeremy | 2005-05-28 10:51:58 -0700
sanity assertions in process method check that @controller, @request, @response are set
r2498@sedna: jeremy | 2005-05-28 10:53:42 -0700
clean up escaping. use instance_variable_get instead of instance_eval. put id in form action instead of hidden input (like the generated scaffolding)
r2499@sedna: jeremy | 2005-05-28 10:54:46 -0700
clean up interpolation, remove tabs from stylesheet
r2500@sedna: jeremy | 2005-05-28 10:56:40 -0700
modernize dynamic scaffolding. use params[:id] instead of @params[id]. use consolidated render method instead of render_action, render_file, etc. use builtin inflections rather than module methods.
r2501@sedna: jeremy | 2005-05-28 11:00:26 -0700
modernize generated scaffolding. use new-style assertions; use params[:id] instead of @params[id]; use consolidated render method instead of render_*
r2542@sedna: jeremy | 2005-06-12 02:24:06 -0700
use :id => model instead of :id => model.id. clean up the form helper method. use flash[:notice] instead of flash['notice'].
r2543@sedna: jeremy | 2005-06-12 02:33:22 -0700
whitespace
r2544@sedna: jeremy | 2005-06-12 02:56:57 -0700
update changelogs
r2545@sedna: jeremy | 2005-06-12 03:26:23 -0700
test dynamic form help when @post is not a new record
r2546@sedna: jeremy | 2005-06-12 03:44:14 -0700
touch up TestCase#process sanity assertions
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1404 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb | 58 |
1 files changed, 38 insertions, 20 deletions
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 c1b934a5d3..3441b56670 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 @@ -16,65 +16,83 @@ class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase <% for action in unscaffolded_actions -%> def test_<%= action %> get :<%= action %> - assert_rendered_file '<%= action %>' + assert_response :success + assert_template '<%= action %>' end <% end -%> <% unless suffix -%> def test_index get :index - assert_rendered_file 'list' + assert_response :success + assert_template 'list' end <% end -%> def test_list<%= suffix %> get :list<%= suffix %> - assert_rendered_file 'list<%= suffix %>' - assert_template_has '<%= plural_name %>' + + assert_response :success + assert_template 'list<%= suffix %>' + + assert_not_nil assigns(:<%= plural_name %>) end def test_show<%= suffix %> - get :show<%= suffix %>, 'id' => 1 - assert_rendered_file 'show' - assert_template_has '<%= singular_name %>' - assert_valid_record '<%= singular_name %>' + get :show<%= suffix %>, :id => 1 + + assert_response :success + assert_template 'show' + + assert_not_nil assigns(:<%= singular_name %>) + assert assigns(:<%= singular_name %>).valid? end def test_new<%= suffix %> get :new<%= suffix %> - assert_rendered_file 'new<%= suffix %>' - assert_template_has '<%= singular_name %>' + + assert_response :success + assert_template 'new<%= suffix %>' + + assert_not_nil assigns(:<%= singular_name %>) end def test_create - num_<%= plural_name %> = <%= model_name %>.find_all.size + num_<%= plural_name %> = <%= model_name %>.count + + post :create<%= suffix %>, :<%= singular_name %> => {} - post :create<%= suffix %>, '<%= singular_name %>' => { } + assert_response :redirect assert_redirected_to :action => 'list<%= suffix %>' - assert_equal num_<%= plural_name %> + 1, <%= model_name %>.find_all.size + assert_equal num_<%= plural_name %> + 1, <%= model_name %>.count end def test_edit<%= suffix %> - get :edit<%= suffix %>, 'id' => 1 - assert_rendered_file 'edit<%= suffix %>' - assert_template_has '<%= singular_name %>' - assert_valid_record '<%= singular_name %>' + get :edit<%= suffix %>, :id => 1 + + assert_response :success + assert_template 'edit<%= suffix %>' + + assert_not_nil assigns(:<%= singular_name %>) + assert assigns(:<%= singular_name %>).valid? end def test_update<%= suffix %> - post :update<%= suffix %>, 'id' => 1 + post :update<%= suffix %>, :id => 1 + assert_response :redirect assert_redirected_to :action => 'show<%= suffix %>', :id => 1 end def test_destroy<%= suffix %> assert_not_nil <%= model_name %>.find(1) - post :destroy, 'id' => 1 + post :destroy, :id => 1 + assert_response :redirect assert_redirected_to :action => 'list<%= suffix %>' assert_raise(ActiveRecord::RecordNotFound) { - <%= singular_name %> = <%= model_name %>.find(1) + <%= model_name %>.find(1) } end end |