From 163152bfd0ea5344472d24b6f89e8c957dbd66f5 Mon Sep 17 00:00:00 2001 From: David Chelimsky Date: Tue, 25 May 2010 00:34:55 -0500 Subject: [PATCH] Support configuration of controller.controller_path on instances of ActionView::TestCase::TestController without stubs. Just say: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @controller.controller_path = "path/i/need/for/this/test" [#4697 state:resolved] Signed-off-by: José Valim --- actionpack/lib/action_view/test_case.rb | 9 +++++++-- actionpack/test/template/test_case_test.rb | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb index 2c66e5ae09..e71761db6d 100644 --- a/actionpack/lib/action_view/test_case.rb +++ b/actionpack/lib/action_view/test_case.rb @@ -10,11 +10,16 @@ module ActionView attr_accessor :request, :response, :params - def self.controller_path - '' + class << self + attr_writer :controller_path + end + + def controller_path=(path) + self.class.controller_path=(path) end def initialize + self.class.controller_path = "" @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new diff --git a/actionpack/test/template/test_case_test.rb b/actionpack/test/template/test_case_test.rb index a4fb9f22bf..25dbc04ce1 100644 --- a/actionpack/test/template/test_case_test.rb +++ b/actionpack/test/template/test_case_test.rb @@ -112,7 +112,7 @@ module ActionView end end - TestController.stubs(:controller_path).returns('test') + @controller.controller_path = 'test' @customers = [stub(:name => 'Eloy'), stub(:name => 'Manfred')] assert_match /Hello: EloyHello: Manfred/, render(:partial => 'test/from_helper') @@ -161,7 +161,7 @@ module ActionView end test "is able to render partials from templates and also use instance variables" do - TestController.stubs(:controller_path).returns('test') + @controller.controller_path = "test" @customers = [stub(:name => 'Eloy'), stub(:name => 'Manfred')] assert_match /Hello: EloyHello: Manfred/, render(:file => 'test/list')