Skip to content
This repository
Browse code

Reuse the view_context from the controller, this make the test enviro…

…nment more similar to the code applications uses
  • Loading branch information...
commit daada51d1051948c3e6de963a90c4b5bb5bf142b 1 parent 6ddabaa
Santiago Pastorino spastorino authored

Showing 1 changed file with 1 addition and 4 deletions. Show diff stats Hide diff stats

  1. +1 4 actionpack/lib/action_view/test_case.rb
5 actionpack/lib/action_view/test_case.rb
@@ -156,11 +156,8 @@ def _render_partial(options)
156 156 # The instance of ActionView::Base that is used by +render+.
157 157 def view
158 158 @view ||= begin
159   - view = ActionView::Base.new(ActionController::Base.view_paths, {}, @controller)
160   - view.singleton_class.send :include, @controller._helpers
  159 + view = @controller.view_context
161 160 view.singleton_class.send :include, _helpers
162   - view.singleton_class.send :include, @controller._routes.url_helpers
163   - view.singleton_class.send :delegate, :alert, :notice, :to => "request.flash"
164 161 view.extend(Locals)
165 162 view.locals = self.locals
166 163 view.output_buffer = self.output_buffer

1 comment on commit daada51

Dmytrii Nagirniak

Pretty sure that this commit breaks tests.

Especially the RSpec ones.
This is happening because of @controller is nil before running the view specs.

See more at rspec/rspec-rails#833 (comment)

Would that be rails' problem or RSpec's and what would be the best way to workaround it?

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