diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-07-24 17:09:38 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-24 17:09:38 -0400 |
commit | bd0d1e212a3db8be3cb7eb5251e736ee5fb07d51 (patch) | |
tree | 227489eee7db8679ce756293423066363cde5d0e /railties | |
parent | d9ca57ab0b5c20af11f4b819e75306c668b203f7 (diff) | |
parent | 2bd60c844ce92047e03359f4dde4b19f49de92ea (diff) | |
download | rails-bd0d1e212a3db8be3cb7eb5251e736ee5fb07d51.tar.gz rails-bd0d1e212a3db8be3cb7eb5251e736ee5fb07d51.tar.bz2 rails-bd0d1e212a3db8be3cb7eb5251e736ee5fb07d51.zip |
Merge pull request #29898 from deivid-rodriguez/follow_up_to_multiple_location_engine_mounting
Fix regression introduced by fixing mounting the same engine in multiple locations
Diffstat (limited to 'railties')
-rw-r--r-- | railties/test/railties/engine_test.rb | 29 | ||||
-rw-r--r-- | railties/test/railties/mounted_engine_test.rb | 9 |
2 files changed, 38 insertions, 0 deletions
diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index 0379394f31..6f762d2d3f 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -1427,6 +1427,35 @@ YAML assert_equal "/vegetables/1/bukkits/posts", last_response.body end + test "route helpers resolve script name correctly when called with different script name from current one" do + @plugin.write "app/controllers/posts_controller.rb", <<-RUBY + class PostsController < ActionController::Base + def index + render plain: fruit_bukkits.posts_path(fruit_id: 2) + end + end + RUBY + + app_file "config/routes.rb", <<-RUBY + Rails.application.routes.draw do + resources :fruits do + mount Bukkits::Engine => "/bukkits" + end + end + RUBY + + @plugin.write "config/routes.rb", <<-RUBY + Bukkits::Engine.routes.draw do + resources :posts, only: :index + end + RUBY + + boot_rails + + get("/fruits/1/bukkits/posts") + assert_equal "/fruits/2/bukkits/posts", last_response.body + end + private def app Rails.application diff --git a/railties/test/railties/mounted_engine_test.rb b/railties/test/railties/mounted_engine_test.rb index 6639e55382..6eb2c5acc6 100644 --- a/railties/test/railties/mounted_engine_test.rb +++ b/railties/test/railties/mounted_engine_test.rb @@ -111,6 +111,7 @@ module ApplicationTests @plugin.write "config/routes.rb", <<-RUBY Blog::Engine.routes.draw do resources :posts + get '/different_context', to: 'posts#different_context' get '/generate_application_route', to: 'posts#generate_application_route' get '/application_route_in_view', to: 'posts#application_route_in_view' get '/engine_polymorphic_path', to: 'posts#engine_polymorphic_path' @@ -125,6 +126,10 @@ module ApplicationTests render plain: blog.post_path(1) end + def different_context + render plain: blog.post_path(1, user: "ada") + end + def generate_application_route path = main_app.url_for(controller: "/main", action: "index", @@ -196,6 +201,10 @@ module ApplicationTests get "/john/blog/posts" assert_equal "/john/blog/posts/1", last_response.body + # test generating engine route from engine with a different context + get "/john/blog/different_context" + assert_equal "/ada/blog/posts/1", last_response.body + # test generating engine's route from engine with default_url_options get "/john/blog/posts", {}, "SCRIPT_NAME" => "/foo" assert_equal "/foo/john/blog/posts/1", last_response.body |