diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2013-12-10 13:07:56 -0800 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2013-12-10 13:07:56 -0800 |
commit | 308f37f94ddec2d2d37519ea751c70128c2a0e6b (patch) | |
tree | 4c1e831fca000ef772ddbac9f8e26df1c89f1323 /actionpack | |
parent | b5c5121f67c88a2be1c56e810f5c64013351ce79 (diff) | |
parent | e6c602da9046a653747ce99c9cab7f08f572fa40 (diff) | |
download | rails-308f37f94ddec2d2d37519ea751c70128c2a0e6b.tar.gz rails-308f37f94ddec2d2d37519ea751c70128c2a0e6b.tar.bz2 rails-308f37f94ddec2d2d37519ea751c70128c2a0e6b.zip |
Merge pull request #12699 from drogus/fix-mounting-engine-in-resources
Fix mounting engines inside a resources block
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG.md | 4 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 3 | ||||
-rw-r--r-- | actionpack/test/dispatch/mount_test.rb | 13 |
3 files changed, 18 insertions, 2 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 5f0f1b78d1..3d507392b1 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,3 +1,7 @@ +* Fix generating a path for engine inside a resources block (#8533) + + *Piotr Sarnacki* + * Add Mime::Type.register "text/vcard", :vcf to the default list of mime types *DHH* diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 846a6345cb..bfba8d143d 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -502,11 +502,12 @@ module ActionDispatch raise "A rack application must be specified" unless path options[:as] ||= app_name(app) + target_as = name_for_action(options[:as], path) options[:via] ||= :all match(path, options.merge(:to => app, :anchor => false, :format => false)) - define_generate_prefix(app, options[:as]) + define_generate_prefix(app, target_as) self end diff --git a/actionpack/test/dispatch/mount_test.rb b/actionpack/test/dispatch/mount_test.rb index 30e95a0b75..683a4f01e2 100644 --- a/actionpack/test/dispatch/mount_test.rb +++ b/actionpack/test/dispatch/mount_test.rb @@ -5,7 +5,7 @@ class TestRoutingMount < ActionDispatch::IntegrationTest class FakeEngine def self.routes - Object.new + @routes ||= ActionDispatch::Routing::RouteSet.new end def self.call(env) @@ -27,12 +27,23 @@ class TestRoutingMount < ActionDispatch::IntegrationTest scope "/its_a" do mount SprocketsApp, :at => "/sprocket" end + + resources :users do + mount FakeEngine, :at => "/fakeengine", :as => :fake_mounted_at_resource + end end def app Router end + def test_app_name_is_properly_generated_when_engine_is_mounted_in_resources + assert Router.mounted_helpers.method_defined?(:user_fake_mounted_at_resource), + "A mounted helper should be defined with a parent's prefix" + assert Router.named_routes.routes[:user_fake_mounted_at_resource], + "A named route should be defined with a parent's prefix" + end + def test_trailing_slash_is_not_removed_from_path_info get "/sprockets/omg/" assert_equal "/sprockets -- /omg/", response.body |