1
0
Fork 0
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:
Vasiliy Ermolovich 2012-06-05 18:50:42 +03:00
parent 5756d83ed0
commit ea3aaf6144

View file

@ -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]
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
example.call
config.before :type => :view do
controller.set_current_view_context
end
end