aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorJeremy Daer <jeremydaer@gmail.com>2016-04-24 15:27:46 -0700
committerJeremy Daer <jeremydaer@gmail.com>2016-04-24 15:27:46 -0700
commit643cac08a325243cab21d870c68a9c4088c58380 (patch)
treea4c4e006015254e7a8249ce323739511340535ec /actionpack/test
parentedc2b7718725016e988089b5fb6d6fb9d6e16882 (diff)
parent8ca8a2d773b942c4ea76baabe2df502a339d05b1 (diff)
downloadrails-643cac08a325243cab21d870c68a9c4088c58380.tar.gz
rails-643cac08a325243cab21d870c68a9c4088c58380.tar.bz2
rails-643cac08a325243cab21d870c68a9c4088c58380.zip
Merge pull request #23103 from rails/refactor-handling-of-action-default
Refactor handling of :action default in routing
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/routing_test.rb4
-rw-r--r--actionpack/test/dispatch/routing/inspector_test.rb2
-rw-r--r--actionpack/test/dispatch/routing_test.rb62
3 files changed, 54 insertions, 14 deletions
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index c477b4156c..168677829a 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -2064,11 +2064,11 @@ class RackMountIntegrationTests < ActiveSupport::TestCase
def test_extras
params = {:controller => 'people'}
assert_equal [], @routes.extra_keys(params)
- assert_equal({:controller => 'people'}, params)
+ assert_equal({:controller => 'people', :action => 'index'}, params)
params = {:controller => 'people', :foo => 'bar'}
assert_equal [:foo], @routes.extra_keys(params)
- assert_equal({:controller => 'people', :foo => 'bar'}, params)
+ assert_equal({:controller => 'people', :action => 'index', :foo => 'bar'}, params)
params = {:controller => 'people', :action => 'create', :person => { :name => 'Josh'}}
assert_equal [:person], @routes.extra_keys(params)
diff --git a/actionpack/test/dispatch/routing/inspector_test.rb b/actionpack/test/dispatch/routing/inspector_test.rb
index 9d0d23d6de..5aafcb23c2 100644
--- a/actionpack/test/dispatch/routing/inspector_test.rb
+++ b/actionpack/test/dispatch/routing/inspector_test.rb
@@ -347,7 +347,7 @@ module ActionDispatch
end
assert_equal ["Prefix Verb URI Pattern Controller#Action",
- " GET /:controller(/:action) (?-mix:api\\/[^\\/]+)#:action"], output
+ " GET /:controller(/:action) :controller#:action"], output
end
def test_inspect_routes_shows_resources_route_when_assets_disabled
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 09830c0c46..ade4b0c381 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -3991,16 +3991,6 @@ class TestUnicodePaths < ActionDispatch::IntegrationTest
end
class TestMultipleNestedController < ActionDispatch::IntegrationTest
- module ::Foo
- module Bar
- class BazController < ActionController::Base
- def index
- render :inline => "<%= url_for :controller => '/pooh', :action => 'index' %>"
- end
- end
- end
- end
-
Routes = ActionDispatch::Routing::RouteSet.new.tap do |app|
app.draw do
namespace :foo do
@@ -4012,7 +4002,18 @@ class TestMultipleNestedController < ActionDispatch::IntegrationTest
end
end
- include Routes.url_helpers
+ module ::Foo
+ module Bar
+ class BazController < ActionController::Base
+ include Routes.url_helpers
+
+ def index
+ render :inline => "<%= url_for :controller => '/pooh', :action => 'index' %>"
+ end
+ end
+ end
+ end
+
APP = build_app Routes
def app; APP end
@@ -4755,3 +4756,42 @@ class TestPartialDynamicPathSegments < ActionDispatch::IntegrationTest
assert_equal(params, request.path_parameters)
end
end
+
+class TestPathParameters < ActionDispatch::IntegrationTest
+ Routes = ActionDispatch::Routing::RouteSet.new.tap do |app|
+ app.draw do
+ scope module: 'test_path_parameters' do
+ scope ':locale', locale: /en|ar/ do
+ root to: 'home#index'
+ get '/about', to: 'pages#about'
+ end
+ end
+
+ get ':controller(/:action/(:id))'
+ end
+ end
+
+ class HomeController < ActionController::Base
+ include Routes.url_helpers
+
+ def index
+ render inline: "<%= root_path %>"
+ end
+ end
+
+ class PagesController < ActionController::Base
+ include Routes.url_helpers
+
+ def about
+ render inline: "<%= root_path(locale: :ar) %> | <%= url_for(locale: :ar) %>"
+ end
+ end
+
+ APP = build_app Routes
+ def app; APP end
+
+ def test_path_parameters_are_not_mutated
+ get '/en/about'
+ assert_equal "/ar | /ar/about", @response.body
+ end
+end