Skip to content
This repository
Browse code

Merge pull request #7580 from spohlenz/mounted-url-helper-ivars

Use internal instance variable naming scheme for mounted URL helpers
  • Loading branch information...
commit 6107407e66aa68cf269ec00b64d7ab3623465b97 2 parents aee9b6a + a79f8bd
José Valim josevalim authored
2  actionpack/lib/action_dispatch/routing/route_set.rb
@@ -319,7 +319,7 @@ def define_mounted_helper(name)
319 319
320 320 MountedHelpers.class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
321 321 def #{name}
322   - @#{name} ||= _#{name}
  322 + @_#{name} ||= _#{name}
323 323 end
324 324 RUBY
325 325 end
11 actionpack/test/dispatch/prefix_generation_test.rb
@@ -57,6 +57,7 @@ def self.routes
57 57 get "/polymorphic_path_for_engine", :to => "outside_engine_generating#polymorphic_path_for_engine"
58 58 get "/polymorphic_with_url_for", :to => "outside_engine_generating#polymorphic_with_url_for"
59 59 get "/conflicting_url", :to => "outside_engine_generating#conflicting"
  60 + get "/ivar_usage", :to => "outside_engine_generating#ivar_usage"
60 61 root :to => "outside_engine_generating#index"
61 62 end
62 63
@@ -125,6 +126,11 @@ def polymorphic_with_url_for
125 126 def conflicting
126 127 render :text => "application"
127 128 end
  129 +
  130 + def ivar_usage
  131 + @blog_engine = "Not the engine route helper"
  132 + render :text => blog_engine.post_path(:id => 1)
  133 + end
128 134 end
129 135
130 136 class EngineObject
@@ -203,6 +209,11 @@ def setup
203 209 assert_equal "http://example.org/awesome/blog/posts/1", last_response.body
204 210 end
205 211
  212 + test "[APP] instance variable with same name as engine" do
  213 + get "/ivar_usage"
  214 + assert_equal "/awesome/blog/posts/1", last_response.body
  215 + end
  216 +
206 217 # Inside any Object
207 218 test "[OBJECT] proxy route should override respond_to?() as expected" do
208 219 assert_respond_to blog_engine, :named_helper_that_should_be_invoked_only_in_respond_to_test_path

0 comments on commit 6107407

Please sign in to comment.
Something went wrong with that request. Please try again.