aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-01-02 13:56:05 -0800
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-01-02 13:56:05 -0800
commitf8452e8de786377ed89d777dabe7d82987f9b001 (patch)
tree763ed8a5a06b24c516ac3c06e71ad553416c8f16 /actionpack/test
parentf4dc7e3676a3a68d92772b5a466d54e430aa7b6a (diff)
parent33841a9db3e560ef062d36d14ea07f7d71dd65ab (diff)
downloadrails-f8452e8de786377ed89d777dabe7d82987f9b001.tar.gz
rails-f8452e8de786377ed89d777dabe7d82987f9b001.tar.bz2
rails-f8452e8de786377ed89d777dabe7d82987f9b001.zip
Merge pull request #8703 from senny/backport_8700
Backport #8701, do not append a second slash with `trailing_slash: true` Closes #8700
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/routing_test.rb20
1 files changed, 15 insertions, 5 deletions
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index 7079a6ff90..becb928a3c 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -58,13 +58,13 @@ class UriReservedCharactersRoutingTest < Test::Unit::TestCase
end
class MockController
- def self.build(helpers)
+ def self.build(helpers, additional_options = {})
Class.new do
- def url_for(options)
+ define_method :url_for do |options|
options[:protocol] ||= "http"
options[:host] ||= "test.host"
- super(options)
+ super(options.merge(additional_options))
end
include helpers
@@ -468,8 +468,8 @@ class LegacyRouteSetTests < Test::Unit::TestCase
routes.send(:pages_url)
end
- def setup_for_named_route
- MockController.build(rs.url_helpers).new
+ def setup_for_named_route(options = {})
+ MockController.build(rs.url_helpers, options).new
end
def test_named_route_without_hash
@@ -487,6 +487,16 @@ class LegacyRouteSetTests < Test::Unit::TestCase
assert_equal("/", routes.send(:root_path))
end
+ def test_named_route_root_with_trailing_slash
+ rs.draw do
+ root :to => "hello#index"
+ end
+
+ routes = setup_for_named_route(trailing_slash: true)
+ assert_equal("http://test.host/", routes.send(:root_url))
+ assert_equal("http://test.host/?foo=bar", routes.send(:root_url, foo: :bar))
+ end
+
def test_named_route_with_regexps
rs.draw do
match 'page/:year/:month/:day/:title' => 'page#show', :as => 'article',