blob: b21e66dcb90ac3294791009bbf5afa10ce20c75a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
require File.dirname(__FILE__) + '/../abstract_unit'
class CallerController < ActionController::Base
def calling_from_controller
render_component(:controller => "callee", :action => "being_called")
end
def calling_from_controller_with_params
render_component(:controller => "callee", :action => "being_called", :params => { "name" => "David" })
end
def calling_from_template
render_template "Ring, ring: <%= render_component(:controller => 'callee', :action => 'being_called') %>"
end
def rescue_action(e) raise end
end
class CalleeController < ActionController::Base
def being_called
render_text "#{@params["name"] || "Lady"} of the House, speaking"
end
def rescue_action(e) raise end
end
class RenderTest < Test::Unit::TestCase
def setup
@controller = CallerController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
def test_calling_from_controller
get :calling_from_controller
assert_equal "Lady of the House, speaking", @response.body
end
def test_calling_from_controller_with_params
get :calling_from_controller_with_params
assert_equal "David of the House, speaking", @response.body
end
def test_calling_from_template
get :calling_from_template
assert_equal "Ring, ring: Lady of the House, speaking", @response.body
end
end
|