Skip to content

Commit

Permalink
Don't override ActionView::Base includes
Browse files Browse the repository at this point in the history
  • Loading branch information
leoc committed Jan 5, 2024
1 parent c1d9c58 commit 4fd7499
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/liquid-rails/rspec/view_controller_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ module ViewControllerContext
extend ActiveSupport::Concern

def setup_view_and_controller
ephemeral_view_class = Class.new(ActionView::Base)

@controller = ActionController::Base.new
@view = ActionView::Base.new(ActionView::LookupContext.new(''), {}, @controller)
@view = ephemeral_view_class.new(ActionView::LookupContext.new(''), {}, @controller)
@request = ActionDispatch::TestRequest.new({ 'PATH_INFO' => '/' })
@response = ActionDispatch::TestResponse.new
@response.request = @request
@controller.request = @request
@controller.response = @response
@controller.params = {}
@view.assign_controller(@controller)
@view.class.send(:include, @controller._helpers)
@view.class.send(:include, ::Rails.application.routes.url_helpers)
ephemeral_view_class.send(:include, @controller._helpers)
ephemeral_view_class.send(:include, ::Rails.application.routes.url_helpers)
end

def view
Expand Down

0 comments on commit 4fd7499

Please sign in to comment.