mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
provide a standard method for establishing a view context in testing situations
This commit is contained in:
parent
4c090ba2a6
commit
b46bb990f1
1 changed files with 12 additions and 0 deletions
12
lib/draper/test/view_context.rb
Normal file
12
lib/draper/test/view_context.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
module Draper
|
||||
module ViewContext
|
||||
def self.infect!(context)
|
||||
context.instance_eval do
|
||||
ApplicationController.new.set_current_view_context
|
||||
Draper::ViewContext.current.controller.request ||= ActionController::TestRequest.new
|
||||
Draper::ViewContext.current.request ||= Draper::ViewContext.current.controller.request
|
||||
Draper::ViewContext.current.params ||= {}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue