1
0
Fork 0
mirror of https://github.com/drapergem/draper synced 2023-03-27 23:21:17 -04:00

Set the view_context properly

This commit is contained in:
Mattias Pfeiffer 2011-10-13 18:12:42 +02:00
parent f55962ddcb
commit ea445dd2d3
2 changed files with 11 additions and 1 deletions

View file

@ -1,7 +1,7 @@
module Draper
module ViewContext
def set_current_view_context
Thread.current[:current_view_context] ||= self.view_context
Thread.current[:current_view_context] = self.view_context
end
def self.included(source)

View file

@ -22,4 +22,14 @@ describe Draper::ViewContext do
Thread.current[:current_view_context] = nil
expect {app_controller.current_view_context}.should raise_exception(Exception)
end
it "sets view_context every time" do
app_controller_instance.stub(:view_context) { 'first' }
app_controller_instance.set_current_view_context
Thread.current[:current_view_context].should == 'first'
app_controller_instance.stub(:view_context) { 'second' }
app_controller_instance.set_current_view_context
Thread.current[:current_view_context].should == 'second'
end
end