Skip to content

Commit

Permalink
Support configuration of controller.controller_path on instances of
Browse files Browse the repository at this point in the history
ActionView::TestCase::TestController without stubs. Just say:

  @controller.controller_path = "path/i/need/for/this/test"

[#4697 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
dchelimsky authored and josevalim committed May 26, 2010
1 parent e3549a8 commit 163152b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions actionpack/lib/action_view/test_case.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ class TestController < ActionController::Base


attr_accessor :request, :response, :params 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 end


def initialize def initialize
self.class.controller_path = ""
@request = ActionController::TestRequest.new @request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new @response = ActionController::TestResponse.new


Expand Down
4 changes: 2 additions & 2 deletions actionpack/test/template/test_case_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def render_from_helper
end end
end end


TestController.stubs(:controller_path).returns('test') @controller.controller_path = 'test'


@customers = [stub(:name => 'Eloy'), stub(:name => 'Manfred')] @customers = [stub(:name => 'Eloy'), stub(:name => 'Manfred')]
assert_match /Hello: EloyHello: Manfred/, render(:partial => 'test/from_helper') assert_match /Hello: EloyHello: Manfred/, render(:partial => 'test/from_helper')
Expand Down Expand Up @@ -161,7 +161,7 @@ def render_from_helper
end end


test "is able to render partials from templates and also use instance variables" do 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')] @customers = [stub(:name => 'Eloy'), stub(:name => 'Manfred')]
assert_match /Hello: EloyHello: Manfred/, render(:file => 'test/list') assert_match /Hello: EloyHello: Manfred/, render(:file => 'test/list')
Expand Down

0 comments on commit 163152b

Please sign in to comment.