aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@plataformatec.com.br>2012-09-09 00:52:50 -0700
committerJosé Valim <jose.valim@plataformatec.com.br>2012-09-09 00:52:50 -0700
commit6107407e66aa68cf269ec00b64d7ab3623465b97 (patch)
tree06f0679c8e8c09f77589b1d949b42a29812c8a0f
parentaee9b6affac3a4232a3914e6bfbe73c1bf9cb689 (diff)
parenta79f8bd25230bda16e3c97d168efa38373ec8749 (diff)
downloadrails-6107407e66aa68cf269ec00b64d7ab3623465b97.tar.gz
rails-6107407e66aa68cf269ec00b64d7ab3623465b97.tar.bz2
rails-6107407e66aa68cf269ec00b64d7ab3623465b97.zip
Merge pull request #7580 from spohlenz/mounted-url-helper-ivars
Use internal instance variable naming scheme for mounted URL helpers
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb2
-rw-r--r--actionpack/test/dispatch/prefix_generation_test.rb11
2 files changed, 12 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 1fe40d8458..060d0bfa2f 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -319,7 +319,7 @@ module ActionDispatch
MountedHelpers.class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
def #{name}
- @#{name} ||= _#{name}
+ @_#{name} ||= _#{name}
end
RUBY
end
diff --git a/actionpack/test/dispatch/prefix_generation_test.rb b/actionpack/test/dispatch/prefix_generation_test.rb
index 6d75c5ec7a..cfbf970a37 100644
--- a/actionpack/test/dispatch/prefix_generation_test.rb
+++ b/actionpack/test/dispatch/prefix_generation_test.rb
@@ -57,6 +57,7 @@ module TestGenerationPrefix
get "/polymorphic_path_for_engine", :to => "outside_engine_generating#polymorphic_path_for_engine"
get "/polymorphic_with_url_for", :to => "outside_engine_generating#polymorphic_with_url_for"
get "/conflicting_url", :to => "outside_engine_generating#conflicting"
+ get "/ivar_usage", :to => "outside_engine_generating#ivar_usage"
root :to => "outside_engine_generating#index"
end
@@ -125,6 +126,11 @@ module TestGenerationPrefix
def conflicting
render :text => "application"
end
+
+ def ivar_usage
+ @blog_engine = "Not the engine route helper"
+ render :text => blog_engine.post_path(:id => 1)
+ end
end
class EngineObject
@@ -203,6 +209,11 @@ module TestGenerationPrefix
assert_equal "http://example.org/awesome/blog/posts/1", last_response.body
end
+ test "[APP] instance variable with same name as engine" do
+ get "/ivar_usage"
+ assert_equal "/awesome/blog/posts/1", last_response.body
+ end
+
# Inside any Object
test "[OBJECT] proxy route should override respond_to?() as expected" do
assert_respond_to blog_engine, :named_helper_that_should_be_invoked_only_in_respond_to_test_path