blob: 7278754b49a4d533de2fdceafb1520d1649dd93e (
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
require 'abstract_unit'
class AssertTemplateController < ActionController::Base
def render_with_partial
render partial: 'test/partial'
end
def render_with_template
render 'test/hello_world'
end
def render_with_layout
@variable_for_layout = 'hello'
render 'test/hello_world', layout: "layouts/standard"
end
def render_with_file
render file: 'README.rdoc'
end
def render_nothing
head :ok
end
end
class AssertTemplateControllerTest < ActionDispatch::IntegrationTest
def test_template_reset_between_requests
get '/assert_template/render_with_template'
assert_template 'test/hello_world'
get '/assert_template/render_nothing'
assert_template nil
end
def test_partial_reset_between_requests
get '/assert_template/render_with_partial'
assert_template partial: 'test/_partial'
get '/assert_template/render_nothing'
assert_template partial: nil
end
def test_layout_reset_between_requests
get '/assert_template/render_with_layout'
assert_template layout: 'layouts/standard'
get '/assert_template/render_nothing'
assert_template layout: nil
end
def test_file_reset_between_requests
get '/assert_template/render_with_file'
assert_template file: 'README.rdoc'
get '/assert_template/render_nothing'
assert_template file: nil
end
def test_template_reset_between_requests_when_opening_a_session
open_session do |session|
session.get '/assert_template/render_with_template'
session.assert_template 'test/hello_world'
session.get '/assert_template/render_nothing'
session.assert_template nil
end
end
def test_partial_reset_between_requests_when_opening_a_session
open_session do |session|
session.get '/assert_template/render_with_partial'
session.assert_template partial: 'test/_partial'
session.get '/assert_template/render_nothing'
session.assert_template partial: nil
end
end
def test_layout_reset_between_requests_when_opening_a_session
open_session do |session|
session.get '/assert_template/render_with_layout'
session.assert_template layout: 'layouts/standard'
session.get '/assert_template/render_nothing'
session.assert_template layout: nil
end
end
def test_file_reset_between_requests_when_opening_a_session
open_session do |session|
session.get '/assert_template/render_with_file'
session.assert_template file: 'README.rdoc'
session.get '/assert_template/render_nothing'
session.assert_template file: nil
end
end
def test_assigns_do_not_reset_template_assertion
get '/assert_template/render_with_layout'
assert_equal 'hello', assigns(:variable_for_layout)
assert_template layout: 'layouts/standard'
end
def test_cookies_do_not_reset_template_assertion
get '/assert_template/render_with_layout'
cookies
assert_template layout: 'layouts/standard'
end
end
|