aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2014-03-08 19:49:11 +0000
committerAndrew White <andyw@pixeltrix.co.uk>2014-03-08 19:51:06 +0000
commitaf4c9b78ff1c967cc1aaef14d34205ef92db8134 (patch)
tree5cde700b701874b8e6fa0acefa94cfbf7dccf97b /actionpack/test/dispatch/routing_test.rb
parent8711086f5a2e73cd068434a5fafef258ba9f4fe1 (diff)
downloadrails-af4c9b78ff1c967cc1aaef14d34205ef92db8134.tar.gz
rails-af4c9b78ff1c967cc1aaef14d34205ef92db8134.tar.bz2
rails-af4c9b78ff1c967cc1aaef14d34205ef92db8134.zip
Copy shallow options from normal options when using scope
If the options :shallow_prefix and :shallow_path are not set in the scope options then copy them from the normal :as and :path options if they are set.
Diffstat (limited to 'actionpack/test/dispatch/routing_test.rb')
-rw-r--r--actionpack/test/dispatch/routing_test.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index e51ece1b2e..a47050adce 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -3223,6 +3223,54 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
assert_equal 'project_files#destroy', @response.body
end
+ def test_scope_path_is_copied_to_shallow_path
+ draw do
+ scope path: 'foo' do
+ resources :posts do
+ resources :comments, shallow: true
+ end
+ end
+ end
+
+ assert_equal '/foo/comments/1', comment_path('1')
+ end
+
+ def test_scope_as_is_copied_to_shallow_prefix
+ draw do
+ scope as: 'foo' do
+ resources :posts do
+ resources :comments, shallow: true
+ end
+ end
+ end
+
+ assert_equal '/comments/1', foo_comment_path('1')
+ end
+
+ def test_scope_shallow_prefix_is_not_overwritten_by_as
+ draw do
+ scope as: 'foo', shallow_prefix: 'bar' do
+ resources :posts do
+ resources :comments, shallow: true
+ end
+ end
+ end
+
+ assert_equal '/comments/1', bar_comment_path('1')
+ end
+
+ def test_scope_shallow_path_is_not_overwritten_by_path
+ draw do
+ scope path: 'foo', shallow_path: 'bar' do
+ resources :posts do
+ resources :comments, shallow: true
+ end
+ end
+ end
+
+ assert_equal '/bar/comments/1', comment_path('1')
+ end
+
private
def draw(&block)