diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-06-29 02:41:00 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-06-29 02:41:00 +0000 |
commit | 31e48939b13b5960eec0167ef0b71cd65ed36ed4 (patch) | |
tree | 077731411abd5d6174db298f52b9c37e222edd90 /actionpack/test | |
parent | 453ed1539500f3dc9f704bb0933f50cc42bbe46a (diff) | |
download | rails-31e48939b13b5960eec0167ef0b71cd65ed36ed4.tar.gz rails-31e48939b13b5960eec0167ef0b71cd65ed36ed4.tar.bz2 rails-31e48939b13b5960eec0167ef0b71cd65ed36ed4.zip |
r1475@iwill: jeremy | 2005-06-28 23:19:51 -0700
Ticket 1543 - Fix test_process
r1476@iwill: jeremy | 2005-06-29 00:20:53 -0700
Correct expected, actual order for assert_equal. Use new render method in TestController.
r1477@iwill: jeremy | 2005-06-29 00:23:45 -0700
Generate route and assign parameters without modifying the user's params.
r1480@iwill: jeremy | 2005-06-29 00:28:52 -0700
Update changelog.
r1481@iwill: jeremy | 2005-06-29 00:34:02 -0700
Directly generate paths with a leading slash instead of tacking it on later.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1557 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 94 | ||||
-rw-r--r-- | actionpack/test/controller/test_test.rb | 10 |
2 files changed, 52 insertions, 52 deletions
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index d7b10f69d9..f5149c84bc 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -354,16 +354,16 @@ not_expired = true c = [Static.new("hello"), Static.new("world")] go c - assert_equal "hello/world", execute({}, {}) + assert_equal "/hello/world", execute({}, {}) end def test_basic_dynamic c = [Static.new("hi"), Dynamic.new(:action)] go c - assert_equal 'hi/index', execute({:action => 'index'}, {:action => 'index'}) - assert_equal 'hi/show', execute({:action => 'show'}, {:action => 'index'}) - assert_equal 'hi/list+people', execute({}, {:action => 'list people'}) + assert_equal '/hi/index', execute({:action => 'index'}, {:action => 'index'}) + assert_equal '/hi/show', execute({:action => 'show'}, {:action => 'index'}) + assert_equal '/hi/list+people', execute({}, {:action => 'list people'}) assert_nil execute({},{}) end @@ -371,21 +371,21 @@ not_expired = true c = [Static.new("hi"), Dynamic.new(:action, :default => 'index')] go c - assert_equal 'hi', execute({:action => 'index'}, {:action => 'index'}) - assert_equal 'hi/show', execute({:action => 'show'}, {:action => 'index'}) - assert_equal 'hi/list+people', execute({}, {:action => 'list people'}) - assert_equal 'hi', execute({}, {}) + assert_equal '/hi', execute({:action => 'index'}, {:action => 'index'}) + assert_equal '/hi/show', execute({:action => 'show'}, {:action => 'index'}) + assert_equal '/hi/list+people', execute({}, {:action => 'list people'}) + assert_equal '/hi', execute({}, {}) end def test_dynamic_with_regexp_condition c = [Static.new("hi"), Dynamic.new(:action, :condition => /^[a-z]+$/)] go c - assert_equal 'hi/index', execute({:action => 'index'}, {:action => 'index'}) + assert_equal '/hi/index', execute({:action => 'index'}, {:action => 'index'}) assert_nil execute({:action => 'fox5'}, {:action => 'index'}) assert_nil execute({:action => 'something_is_up'}, {:action => 'index'}) assert_nil execute({}, {:action => 'list people'}) - assert_equal 'hi/abunchofcharacter', execute({:action => 'abunchofcharacter'}, {}) + assert_equal '/hi/abunchofcharacter', execute({:action => 'abunchofcharacter'}, {}) assert_nil execute({}, {}) end @@ -393,25 +393,25 @@ not_expired = true c = [Static.new("hi"), Dynamic.new(:action, :default => 'index', :condition => /^[a-z]+$/)] go c - assert_equal 'hi', execute({:action => 'index'}, {:action => 'index'}) + assert_equal '/hi', execute({:action => 'index'}, {:action => 'index'}) assert_nil execute({:action => 'fox5'}, {:action => 'index'}) assert_nil execute({:action => 'something_is_up'}, {:action => 'index'}) assert_nil execute({}, {:action => 'list people'}) - assert_equal 'hi/abunchofcharacter', execute({:action => 'abunchofcharacter'}, {}) - assert_equal 'hi', execute({}, {}) + assert_equal '/hi/abunchofcharacter', execute({:action => 'abunchofcharacter'}, {}) + assert_equal '/hi', execute({}, {}) end def test_path c = [Static.new("hi"), Path.new(:file)] go c - assert_equal 'hi', execute({:file => []}, {}) - assert_equal 'hi/books/agile_rails_dev.pdf', execute({:file => %w(books agile_rails_dev.pdf)}, {}) - assert_equal 'hi/books/development%26whatever/agile_rails_dev.pdf', execute({:file => %w(books development&whatever agile_rails_dev.pdf)}, {}) + assert_equal '/hi', execute({:file => []}, {}) + assert_equal '/hi/books/agile_rails_dev.pdf', execute({:file => %w(books agile_rails_dev.pdf)}, {}) + assert_equal '/hi/books/development%26whatever/agile_rails_dev.pdf', execute({:file => %w(books development&whatever agile_rails_dev.pdf)}, {}) - assert_equal 'hi', execute({:file => ''}, {}) - assert_equal 'hi/books/agile_rails_dev.pdf', execute({:file => 'books/agile_rails_dev.pdf'}, {}) - assert_equal 'hi/books/development%26whatever/agile_rails_dev.pdf', execute({:file => 'books/development&whatever/agile_rails_dev.pdf'}, {}) + assert_equal '/hi', execute({:file => ''}, {}) + assert_equal '/hi/books/agile_rails_dev.pdf', execute({:file => 'books/agile_rails_dev.pdf'}, {}) + assert_equal '/hi/books/development%26whatever/agile_rails_dev.pdf', execute({:file => 'books/development&whatever/agile_rails_dev.pdf'}, {}) end def test_controller @@ -419,10 +419,10 @@ not_expired = true go c assert_nil execute({}, {}) - assert_equal 'hi/content', execute({:controller => 'content'}, {}) - assert_equal 'hi/admin/user', execute({:controller => 'admin/user'}, {}) - assert_equal 'hi/content', execute({}, {:controller => 'content'}) - assert_equal 'hi/admin/user', execute({}, {:controller => 'admin/user'}) + assert_equal '/hi/content', execute({:controller => 'content'}, {}) + assert_equal '/hi/admin/user', execute({:controller => 'admin/user'}, {}) + assert_equal '/hi/content', execute({}, {:controller => 'content'}) + assert_equal '/hi/admin/user', execute({}, {:controller => 'admin/user'}) end def test_standard_route(time = ::RunTimeTests) @@ -430,13 +430,13 @@ not_expired = true go c # Make sure we get the right answers - assert_equal('content', execute({:action => 'index'}, {:controller => 'content', :action => 'list'})) - assert_equal('content/list', execute({:action => 'list'}, {:controller => 'content', :action => 'index'})) - assert_equal('content/show/10', execute({:action => 'show', :id => '10'}, {:controller => 'content', :action => 'list'})) + assert_equal('/content', execute({:action => 'index'}, {:controller => 'content', :action => 'list'})) + assert_equal('/content/list', execute({:action => 'list'}, {:controller => 'content', :action => 'index'})) + assert_equal('/content/show/10', execute({:action => 'show', :id => '10'}, {:controller => 'content', :action => 'list'})) - assert_equal('admin/user', execute({:action => 'index'}, {:controller => 'admin/user', :action => 'list'})) - assert_equal('admin/user/list', execute({:action => 'list'}, {:controller => 'admin/user', :action => 'index'})) - assert_equal('admin/user/show/10', execute({:action => 'show', :id => '10'}, {:controller => 'admin/user', :action => 'list'})) + assert_equal('/admin/user', execute({:action => 'index'}, {:controller => 'admin/user', :action => 'list'})) + assert_equal('/admin/user/list', execute({:action => 'list'}, {:controller => 'admin/user', :action => 'index'})) + assert_equal('/admin/user/show/10', execute({:action => 'show', :id => '10'}, {:controller => 'admin/user', :action => 'list'})) if time GC.start @@ -467,9 +467,9 @@ not_expired = true assert_nil execute({:controller => 'content', :action => 'elcome'}, {}) assert_nil execute({:action => 'elcome'}, {:controller => 'content'}) - assert_equal '', execute({:controller => 'content', :action => 'welcome'}, {}) - assert_equal '', execute({:action => 'welcome'}, {:controller => 'content'}) - assert_equal '', execute({:action => 'welcome', :id => '10'}, {:controller => 'content'}) + assert_equal '/', execute({:controller => 'content', :action => 'welcome'}, {}) + assert_equal '/', execute({:action => 'welcome'}, {:controller => 'content'}) + assert_equal '/', execute({:action => 'welcome', :id => '10'}, {:controller => 'content'}) end end @@ -509,8 +509,8 @@ class RouteTests < Test::Unit::TestCase assert_nil gen(:known => 'foo') assert_nil gen({}) - assert_equal 'hello/world', gen(:known => 'known_value') - assert_equal 'hello/world', gen(:known => 'known_value', :extra => 'hi') + assert_equal '/hello/world', gen(:known => 'known_value') + assert_equal '/hello/world', gen(:known => 'known_value', :extra => 'hi') assert_equal [:extra], route.extra_keys(:known => 'known_value', :extra => 'hi') end @@ -525,8 +525,8 @@ class RouteTests < Test::Unit::TestCase assert_nil gen(:controller => 'content', :action => 'show_dude', :name => 'rails') assert_nil gen(:controller => 'content', :action => 'show_person') assert_nil gen(:controller => 'admin/user', :action => 'show_person', :name => 'rails') - assert_equal 'hello/rails', gen(:controller => 'content', :action => 'show_person', :name => 'rails') - assert_equal 'hello/Nicholas+Seckar', gen(:controller => 'content', :action => 'show_person', :name => 'Nicholas Seckar') + assert_equal '/hello/rails', gen(:controller => 'content', :action => 'show_person', :name => 'rails') + assert_equal '/hello/Nicholas+Seckar', gen(:controller => 'content', :action => 'show_person', :name => 'Nicholas Seckar') end def test_typical @@ -544,14 +544,14 @@ class RouteTests < Test::Unit::TestCase assert_equal({:controller => ::Controllers::ContentController, :action => 'show', :id => '10'}, rec('content/show/10')) - assert_equal 'content', gen(:controller => 'content', :action => 'index') - assert_equal 'content/list', gen(:controller => 'content', :action => 'list') - assert_equal 'content/show/10', gen(:controller => 'content', :action => 'show', :id => '10') + assert_equal '/content', gen(:controller => 'content', :action => 'index') + assert_equal '/content/list', gen(:controller => 'content', :action => 'list') + assert_equal '/content/show/10', gen(:controller => 'content', :action => 'show', :id => '10') - assert_equal 'admin/user', gen(:controller => 'admin/user', :action => 'index') - assert_equal 'admin/user', gen(:controller => 'admin/user') - assert_equal 'admin/user', gen({:controller => 'admin/user'}, {:controller => 'content', :action => 'list', :id => '10'}) - assert_equal 'admin/user/show/10', gen(:controller => 'admin/user', :action => 'show', :id => '10') + assert_equal '/admin/user', gen(:controller => 'admin/user', :action => 'index') + assert_equal '/admin/user', gen(:controller => 'admin/user') + assert_equal '/admin/user', gen({:controller => 'admin/user'}, {:controller => 'content', :action => 'list', :id => '10'}) + assert_equal '/admin/user/show/10', gen(:controller => 'admin/user', :action => 'show', :id => '10') end end @@ -569,10 +569,10 @@ class RouteSetTests < Test::Unit::TestCase assert_equal({:controller => ::Controllers::Admin::UserController, :action => 'show', :id => '10'}.stringify_keys, rs.recognize_path(%w(admin user show 10))) - assert_equal ['admin/user/show/10', {}], rs.generate({:controller => 'admin/user', :action => 'show', :id => 10}) + assert_equal ['/admin/user/show/10', {}], rs.generate({:controller => 'admin/user', :action => 'show', :id => 10}) - assert_equal ['admin/user/show', {}], rs.generate({:action => 'show'}, {:controller => 'admin/user', :action => 'list', :id => '10'}) - assert_equal ['admin/user/list/10', {}], rs.generate({}, {:controller => 'admin/user', :action => 'list', :id => '10'}) + assert_equal ['/admin/user/show', {}], rs.generate({:action => 'show'}, {:controller => 'admin/user', :action => 'list', :id => '10'}) + assert_equal ['/admin/user/list/10', {}], rs.generate({}, {:controller => 'admin/user', :action => 'list', :id => '10'}) end def test_ignores_leading_slash @@ -674,7 +674,7 @@ class RouteSetTests < Test::Unit::TestCase end def test_changing_controller - assert_equal ['admin/stuff/show/10', {}], rs.generate( + assert_equal ['/admin/stuff/show/10', {}], rs.generate( {:controller => 'stuff', :action => 'show', :id => 10}, {:controller => 'admin/user', :action => 'index'} ) diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb index ec067cc6c0..c754db70ed 100644 --- a/actionpack/test/controller/test_test.rb +++ b/actionpack/test/controller/test_test.rb @@ -7,11 +7,11 @@ class TestTest < Test::Unit::TestCase end def test_uri - render_text @request.request_uri + render :text => request.request_uri end def test_html_output - render_text <<HTML + render :text => <<HTML <html> <body> <div id="foo"> @@ -54,18 +54,18 @@ HTML def test_process_with_request_uri_with_no_params process :test_uri - assert_equal @response.body, "/test_test/test/test_uri" + assert_equal "/test_test/test/test_uri", @response.body end def test_process_with_request_uri_with_params process :test_uri, :id => 7 - assert_equal @response.body, "/test_test/test/test_uri/7" + assert_equal "/test_test/test/test_uri/7", @response.body end def test_process_with_request_uri_with_params_with_explicit_uri @request.set_REQUEST_URI "/explicit/uri" process :test_uri, :id => 7 - assert_equal @response.body, "/explicit/uri" + assert_equal "/explicit/uri", @response.body end def test_assert_tag |