lib/draper/view_context/build_strategy.rb in draper-3.0.0.pre1 vs lib/draper/view_context/build_strategy.rb in draper-3.0.0
- old
+ new
@@ -35,12 +35,21 @@
private
attr_reader :block
def controller
- (Draper::ViewContext.controller || ApplicationController.new).tap do |controller|
- controller.request ||= ActionController::TestRequest.create
+ Draper::ViewContext.controller ||= Draper.default_controller.new
+ Draper::ViewContext.controller.tap do |controller|
+ controller.request ||= new_test_request controller if defined?(ActionController::TestRequest)
end
+ end
+
+ def new_test_request(controller)
+ is_above_rails_5_1 ? ActionController::TestRequest.create(controller) : ActionController::TestRequest.create
+ end
+
+ def is_above_rails_5_1
+ ActionController::TestRequest.method(:create).parameters.first == [:req, :controller_class]
end
end
end
end