Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8645

Show
Ignore:
Timestamp:
01/16/08 01:41:31 (4 months ago)
Author:
nzkoz
Message:

Ensure that the tests use the instance-level view-paths correctly. Closes #10820 [lifofifo]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller/base.rb

    r8633 r8645  
    643643      # View load paths for controller. 
    644644      def view_paths 
    645         (@template || self.class).view_paths 
     645        @template.view_paths 
    646646      end 
    647647     
    648648      def view_paths=(value) 
    649         (@template || self.class).view_paths = value 
     649        @template.view_paths = value 
    650650      end 
    651651 
     
    657657      # 
    658658      def prepend_view_path(path) 
    659         (@template || self.class).prepend_view_path(path) 
     659        @template.prepend_view_path(path) 
    660660      end 
    661661       
     
    667667      # 
    668668      def append_view_path(path) 
    669         (@template || self.class).append_view_path(path) 
     669      @template.append_view_path(path) 
    670670      end 
    671671 
     
    11201120        end 
    11211121 
    1122         response.template = ActionView::Base.new(view_paths, {}, self) 
     1122        response.template = ActionView::Base.new(self.class.view_paths, {}, self) 
    11231123        response.template.extend self.class.master_helper_module 
    11241124        response.redirected_to = nil 
  • trunk/actionpack/test/controller/view_paths_test.rb

    r8564 r8645  
    2929    TestController.view_paths = nil 
    3030    ActionView::Base.cache_template_extensions = false 
    31     @controller = TestController.new 
     31 
    3232    @request  = ActionController::TestRequest.new 
    3333    @response = ActionController::TestResponse.new 
    34    
     34 
     35    @controller = TestController.new 
     36    # Following is needed in order to setup @controller.template object properly 
     37    @controller.send :initialize_template_class, @response 
     38    @controller.send :assign_shortcuts, @request, @response 
     39 
    3540    # Track the last warning. 
    3641    @old_behavior = ActiveSupport::Deprecation.behavior 
     
    4954   
    5055  def test_controller_appends_view_path_correctly 
    51     TestController.append_view_path 'foo' 
     56    @controller.append_view_path 'foo' 
    5257    assert_equal [LOAD_PATH_ROOT, 'foo'], @controller.view_paths 
    5358     
    54     TestController.append_view_path(%w(bar baz)) 
     59    @controller.append_view_path(%w(bar baz)) 
    5560    assert_equal [LOAD_PATH_ROOT, 'foo', 'bar', 'baz'], @controller.view_paths 
    5661  end 
    5762   
    5863  def test_controller_prepends_view_path_correctly 
    59     TestController.prepend_view_path 'baz' 
     64    @controller.prepend_view_path 'baz' 
    6065    assert_equal ['baz', LOAD_PATH_ROOT], @controller.view_paths 
    6166     
    62     TestController.prepend_view_path(%w(foo bar)) 
     67    @controller.prepend_view_path(%w(foo bar)) 
    6368    assert_equal ['foo', 'bar', 'baz', LOAD_PATH_ROOT], @controller.view_paths 
    6469  end