aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2019-01-18 15:07:22 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2019-01-18 15:07:22 -0800
commit8611b15924c5deb083221026b93792e36400bb02 (patch)
treed9f786f3eb9fe50ca21e786d4c2bc91747bfe2c4 /actionpack/lib/action_dispatch
parent63d96adb685ae3cf464327c59a090ede25c55414 (diff)
downloadrails-8611b15924c5deb083221026b93792e36400bb02.tar.gz
rails-8611b15924c5deb083221026b93792e36400bb02.tar.bz2
rails-8611b15924c5deb083221026b93792e36400bb02.zip
Only cache the view_context_class in one place
This patch removes the instance writer of view_context_class. Subclasses may override it, but it doesn't need to be written. This also eliminates the need to cache the return value of the class level `view_context_class` method.
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/testing/assertions/routing.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/testing/assertions/routing.rb b/actionpack/lib/action_dispatch/testing/assertions/routing.rb
index af41521c5c..28cde6704e 100644
--- a/actionpack/lib/action_dispatch/testing/assertions/routing.rb
+++ b/actionpack/lib/action_dispatch/testing/assertions/routing.rb
@@ -160,9 +160,16 @@ module ActionDispatch
@controller.singleton_class.include(_routes.url_helpers)
if @controller.respond_to? :view_context_class
- @controller.view_context_class = Class.new(@controller.view_context_class) do
+ view_context_class = Class.new(@controller.view_context_class) do
include _routes.url_helpers
end
+
+ custom_view_context = Module.new {
+ define_method(:view_context_class) do
+ view_context_class
+ end
+ }
+ @controller.extend(custom_view_context)
end
end
yield @routes