diff options
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 30 | ||||
-rw-r--r-- | actionpack/test/template/form_helper_test.rb | 20 | ||||
-rw-r--r-- | actionpack/test/template/render_test.rb | 2 | ||||
-rw-r--r-- | actionpack/test/template/url_helper_test.rb | 7 |
4 files changed, 48 insertions, 11 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index a4b8fafa78..c90c1041ed 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -442,6 +442,16 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest get :preview, :on => :member end + match '/purchases/:token/:filename', + :to => 'purchases#fetch', + :token => /[[:alnum:]]{10}/, + :filename => /(.+)/, + :as => :purchase + + resources :lists, :id => /([A-Za-z0-9]{25})|default/ do + resources :todos, :id => /\d+/ + end + scope '/countries/:country', :constraints => lambda { |params, req| %[all France].include?(params[:country]) } do match '/', :to => 'countries#index' match '/cities', :to => 'countries#cities' @@ -2098,6 +2108,26 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest assert_equal '/customers/1/export', customer_export_path(:customer_id => '1') end + def test_named_character_classes_in_regexp_constraints + get '/purchases/315004be7e/Ruby_on_Rails_3.pdf' + assert_equal 'purchases#fetch', @response.body + assert_equal '/purchases/315004be7e/Ruby_on_Rails_3.pdf', purchase_path(:token => '315004be7e', :filename => 'Ruby_on_Rails_3.pdf') + end + + def test_nested_resource_constraints + get '/lists/01234012340123401234fffff' + assert_equal 'lists#show', @response.body + assert_equal '/lists/01234012340123401234fffff', list_path(:id => '01234012340123401234fffff') + + get '/lists/01234012340123401234fffff/todos/1' + assert_equal 'todos#show', @response.body + assert_equal '/lists/01234012340123401234fffff/todos/1', list_todo_path(:list_id => '01234012340123401234fffff', :id => '1') + + get '/lists/2/todos/1' + assert_equal 'Not Found', @response.body + assert_raises(ActionController::RoutingError){ list_todo_path(:list_id => '2', :id => '1') } + end + private def with_test_routes yield diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index fd801e2a9e..9a1fe01872 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -641,6 +641,18 @@ class FormHelperTest < ActionView::TestCase assert_dom_equal expected, output_buffer end + def test_form_for_with_format + form_for(@post, :format => :json, :html => { :id => "edit_post_123", :class => "edit_post" }) do |f| + concat f.label(:title) + end + + expected = whole_form("/posts/123.json", "edit_post_123" , "edit_post", :method => "put") do + "<label for='post_title'>Title</label>" + end + + assert_dom_equal expected, output_buffer + end + def test_form_for_with_symbol_object_name form_for(@post, :as => "other_name", :html => { :id => 'create-post' }) do |f| concat f.label(:title, :class => 'post_title') @@ -1761,8 +1773,12 @@ class FormHelperTest < ActionView::TestCase "/posts" end - def post_path(post) - "/posts/#{post.id}" + def post_path(post, options = {}) + if options[:format] + "/posts/#{post.id}.#{options[:format]}" + else + "/posts/#{post.id}" + end end def protect_against_forgery? diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 229766612f..c17bec891b 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -69,8 +69,6 @@ module RenderTestCases end def test_render_update - # TODO: You should not have to stub out template because template is self! - @view.instance_variable_set(:@template, @view) assert_equal 'alert("Hello, World!");', @view.render(:update) { |page| page.alert('Hello, World!') } end diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 19effbc82f..b76813c554 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -24,13 +24,6 @@ class UrlHelperTest < ActiveSupport::TestCase include ActionView::Context include RenderERBUtils - # self.default_url_options = {:host => "www.example.com"} - - # TODO: This shouldn't be needed (see template.rb:53) - def assigns - {} - end - def hash_for(opts = []) ActiveSupport::OrderedHash[*([:controller, "foo", :action, "bar"].concat(opts))] end |