@@ -83,6 +83,22 @@ def test_default_translation
83
83
end
84
84
end
85
85
86
+ def test_default_translation_as_safe_html
87
+ @controller . stub :action_name , :index do
88
+ translation = @controller . t ( ".twoz" , default : [ "<tag>" ] )
89
+ assert_equal "<tag>" , translation
90
+ assert_equal true , translation . html_safe?
91
+ end
92
+ end
93
+
94
+ def test_default_translation_with_raise_as_safe_html
95
+ @controller . stub :action_name , :index do
96
+ translation = @controller . t ( ".twoz" , raise : true , default : [ "<tag>" ] )
97
+ assert_equal "<tag>" , translation
98
+ assert_equal true , translation . html_safe?
99
+ end
100
+ end
101
+
86
102
def test_localize
87
103
time , expected = Time . gm ( 2000 ) , "Sat, 01 Jan 2000 00:00:00 +0000"
88
104
I18n . stub :localize , expected do
@@ -126,6 +142,21 @@ def test_translate_escapes_interpolations_in_translations_with_a_html_suffix
126
142
assert_equal true , translation . html_safe?
127
143
end
128
144
end
145
+
146
+ def test_translate_marks_translation_with_missing_html_key_as_safe_html
147
+ @controller . stub :action_name , :index do
148
+ translation = @controller . t ( "<tag>.html" )
149
+ assert_equal "translation missing: <tag>.html" , translation
150
+ assert_equal false , translation . html_safe?
151
+ end
152
+ end
153
+ def test_translate_marks_translation_with_missing_nested_html_key_as_safe_html
154
+ @controller . stub :action_name , :index do
155
+ translation = @controller . t ( ".<tag>.html" )
156
+ assert_equal "translation missing: abstract_controller.testing.translation.index.<tag>.html" , translation
157
+ assert_equal false , translation . html_safe?
158
+ end
159
+ end
129
160
end
130
161
end
131
162
end
0 commit comments