blob: 3035ed4ff2964aee8cf1eb3c4ca75bd77d2dfdca (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
require 'abstract_unit'
module RenderTemplate
class RenderOnceController < ActionController::Base
layout false
RESOLVER = ActionView::FixtureResolver.new(
"test/a.html.erb" => "a",
"test/b.html.erb" => "<>",
"test/c.html.erb" => "c",
"test/one.html.erb" => "<%= render :once => 'result' %>",
"test/two.html.erb" => "<%= render :once => 'result' %>",
"test/three.html.erb" => "<%= render :once => 'result' %>",
"test/result.html.erb" => "YES!",
"other/result.html.erb" => "NO!",
"layouts/test.html.erb" => "l<%= yield %>l"
)
self.view_paths = [RESOLVER]
def _prefix
"test"
end
def multiple
render :once => %w(a b c)
end
def once
render :once => %w(one two three)
end
def duplicate
render :once => %w(a a a)
end
def with_layout
render :once => %w(a b c), :layout => "test"
end
def with_prefix
render :once => "result", :prefix => "other"
end
def with_nil_prefix
render :once => "test/result", :prefix => nil
end
end
module Tests
def test_mutliple_arguments_get_all_rendered
get :multiple
assert_response "a\n<>\nc"
end
def test_referenced_templates_get_rendered_once
get :once
assert_response "YES!\n\n"
end
def test_duplicated_templates_get_rendered_once
get :duplicate
assert_response "a"
end
def test_layout_wraps_all_rendered_templates
get :with_layout
assert_response "la\n<>\ncl"
end
def test_with_prefix_option
get :with_prefix
assert_response "NO!"
end
def test_with_nil_prefix_option
get :with_nil_prefix
assert_response "YES!"
end
end
class TestRenderOnce < Rack::TestCase
testing RenderTemplate::RenderOnceController
include Tests
end
end
|