mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
set current view context in view tests
use before filter in Rspec instead of around
This commit is contained in:
parent
5756d83ed0
commit
ea3aaf6144
1 changed files with 9 additions and 8 deletions
|
@ -12,14 +12,15 @@ RSpec.configure do |config|
|
|||
}
|
||||
|
||||
# Specs tagged type: :decorator set the Draper view context
|
||||
config.around do |example|
|
||||
if :decorator == example.metadata[:type]
|
||||
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
|
||||
example.call
|
||||
config.before :type => :decorator 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
|
||||
|
||||
config.before :type => :view do
|
||||
controller.set_current_view_context
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue