aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing
diff options
context:
space:
mode:
authorAndrew White <andrew.white@unboxed.co>2017-02-20 13:54:06 +0000
committerAndrew White <andrew.white@unboxed.co>2017-02-21 15:30:46 +0000
commite96da0a7beb483ed5e8a8096ff67b09ecc5ca7a1 (patch)
tree23d81d0dbc88384f7834e74ed9b3cbf9262c0ffa /actionpack/test/dispatch/routing
parent47a27e8950ad00654e2ba0420cefd87269e08055 (diff)
downloadrails-e96da0a7beb483ed5e8a8096ff67b09ecc5ca7a1.tar.gz
rails-e96da0a7beb483ed5e8a8096ff67b09ecc5ca7a1.tar.bz2
rails-e96da0a7beb483ed5e8a8096ff67b09ecc5ca7a1.zip
Only accept symbols and strings for Mapper#direct
Diffstat (limited to 'actionpack/test/dispatch/routing')
-rw-r--r--actionpack/test/dispatch/routing/custom_url_helpers_test.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/routing/custom_url_helpers_test.rb b/actionpack/test/dispatch/routing/custom_url_helpers_test.rb
index a55ee8e9b0..bf4b323cf0 100644
--- a/actionpack/test/dispatch/routing/custom_url_helpers_test.rb
+++ b/actionpack/test/dispatch/routing/custom_url_helpers_test.rb
@@ -31,6 +31,7 @@ class TestCustomUrlHelpers < ActionDispatch::IntegrationTest
end
direct(:website) { "http://www.rubyonrails.org" }
+ direct("string") { "http://www.rubyonrails.org" }
direct(:linkable) { |linkable| [:"#{linkable.linkable_type}", { id: linkable.id }] }
direct(:params) { |params| params }
direct(:symbol) { :basket }
@@ -61,6 +62,9 @@ class TestCustomUrlHelpers < ActionDispatch::IntegrationTest
assert_equal "http://www.rubyonrails.org", website_path
assert_equal "http://www.rubyonrails.org", Routes.url_helpers.website_path
+ assert_equal "http://www.rubyonrails.org", string_path
+ assert_equal "http://www.rubyonrails.org", Routes.url_helpers.string_path
+
assert_equal "/categories/1", linkable_path(@category)
assert_equal "/categories/1", Routes.url_helpers.linkable_path(@category)
assert_equal "/collections/2", linkable_path(@collection)
@@ -92,6 +96,9 @@ class TestCustomUrlHelpers < ActionDispatch::IntegrationTest
assert_equal "http://www.rubyonrails.org", website_url
assert_equal "http://www.rubyonrails.org", Routes.url_helpers.website_url
+ assert_equal "http://www.rubyonrails.org", string_url
+ assert_equal "http://www.rubyonrails.org", Routes.url_helpers.string_url
+
assert_equal "http://www.example.com/categories/1", linkable_url(@category)
assert_equal "http://www.example.com/categories/1", Routes.url_helpers.linkable_url(@category)
assert_equal "http://www.example.com/collections/2", linkable_url(@collection)
@@ -118,4 +125,14 @@ class TestCustomUrlHelpers < ActionDispatch::IntegrationTest
assert_equal "http://www.example.com/products?size=20", defaults_url(size: 20)
assert_equal "http://www.example.com/products?size=20", Routes.url_helpers.defaults_url(size: 20)
end
+
+ def test_raises_argument_error
+ routes = ActionDispatch::Routing::RouteSet.new
+
+ assert_raises ArgumentError do
+ routes.draw do
+ direct(1) { "http://www.rubyonrails.org" }
+ end
+ end
+ end
end