aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/dispatch/routing/concerns_test.rb27
1 files changed, 15 insertions, 12 deletions
diff --git a/actionpack/test/dispatch/routing/concerns_test.rb b/actionpack/test/dispatch/routing/concerns_test.rb
index 0289f38ba7..9f37701656 100644
--- a/actionpack/test/dispatch/routing/concerns_test.rb
+++ b/actionpack/test/dispatch/routing/concerns_test.rb
@@ -2,19 +2,15 @@ require 'abstract_unit'
class RoutingConcernsTest < ActionDispatch::IntegrationTest
class Reviewable
- def self.call(mapper)
- if mapper.current_scope[:controller] == 'posts'
- mapper.resources :reviews
- elsif mapper.current_scope[:controller] == 'videos'
- mapper.resources :reviews, as: :video_reviews
- end
+ def self.call(mapper, options = {})
+ mapper.resources :reviews, options
end
end
Routes = ActionDispatch::Routing::RouteSet.new.tap do |app|
app.draw do
- concern :commentable do
- resources :comments
+ concern :commentable do |options|
+ resources :comments, options
end
concern :image_attachable do
@@ -24,7 +20,9 @@ class RoutingConcernsTest < ActionDispatch::IntegrationTest
concern :reviewable, Reviewable
resources :posts, concerns: [:commentable, :image_attachable, :reviewable] do
- resource :video, concerns: [:commentable, :reviewable]
+ resource :video, concerns: :commentable do
+ concerns :reviewable, as: :video_reviews
+ end
end
resource :picture, concerns: :commentable do
@@ -32,7 +30,7 @@ class RoutingConcernsTest < ActionDispatch::IntegrationTest
end
scope "/videos" do
- concerns :commentable
+ concerns :commentable, except: :destroy
end
end
end
@@ -75,13 +73,13 @@ class RoutingConcernsTest < ActionDispatch::IntegrationTest
assert_equal "404", @response.code
end
- def test_accessing_callable_concern_from_resources
+ def test_accessing_callable_concern_
get "/posts/1/reviews/1"
assert_equal "200", @response.code
assert_equal "/posts/1/reviews/1", post_review_path(post_id: 1, id: 1)
end
- def test_callable_concern_can_adapt_to_mapper
+ def test_callable_concerns_accept_options
get "/posts/1/video/reviews/1"
assert_equal "200", @response.code
assert_equal "/posts/1/video/reviews/1", post_video_video_review_path(post_id: 1, id: 1)
@@ -92,6 +90,11 @@ class RoutingConcernsTest < ActionDispatch::IntegrationTest
assert_equal "200", @response.code
end
+ def test_concerns_accept_options
+ delete "/videos/comments/1"
+ assert_equal "404", @response.code
+ end
+
def test_with_an_invalid_concern_name
e = assert_raise ArgumentError do
ActionDispatch::Routing::RouteSet.new.tap do |app|