/
helper_test.rb
112 lines (85 loc) · 4.07 KB
/
helper_test.rb
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
111
require 'test_helper'
class FormatizeHelperTest < ActionView::TestCase
tests Formatize::Helper
def test_action_view_includes_formatize
assert ActionView::Base.include?(Formatize::Helper)
end
def test_textilize_should_be_html_safe
assert textilize("*This is Textile!* Rejoice!").html_safe?
end
def test_textilize
assert_equal("<p><strong>This is Textile!</strong> Rejoice!</p>", textilize("*This is Textile!* Rejoice!"))
end
def test_textilize_with_blank
assert_equal("", textilize(""))
end
def test_textilize_with_flags
assert_equal("<p>This is worded <strong>strongly</strong></p>", textilize("This is worded <strong>strongly</strong>", :filter_html))
end
def test_textilize_should_sanitize_unsafe_input
assert_equal("<p>This is worded <strong>strongly</strong></p>", textilize("This is worded <strong>strongly</strong><script>code!</script>"))
end
def test_textilize_should_raise_error_if_safe_flag
assert_raise ArgumentError do
textilize("", :safe)
end
end
def test_textilize_should_not_sanitize_safe_input
assert_equal("<p>This is worded <strong>strongly</strong><script>code!</script></p>", textilize("This is worded <strong>strongly</strong><script>code!</script>".html_safe))
end
def test_textilize_with_hard_breaks
assert_equal("<p>This is one scary world.<br />\n True.</p>", textilize("This is one scary world.\n True."))
end
def test_textilize_without_paragraph_should_be_html_safe
textilize_without_paragraph("*This is Textile!* Rejoice!").html_safe?
end
def test_textilize_without_paragraph
assert_equal("<strong>This is Textile!</strong> Rejoice!", textilize_without_paragraph("*This is Textile!* Rejoice!"))
end
def test_textilize_without_paragraph_with_blank
assert_equal("", textilize_without_paragraph(""))
end
def test_textilize_without_paragraph_with_flags
assert_equal("This is worded <strong>strongly</strong>", textilize_without_paragraph("This is worded <strong>strongly</strong>", :filter_html))
end
def test_textilize_without_paragraph_should_sanitize_unsafe_input
assert_equal("This is worded <strong>strongly</strong>", textilize_without_paragraph("This is worded <strong>strongly</strong><script>code!</script>"))
end
def test_textilize_without_paragraph_should_raise_error_if_safe_flag
assert_raise ArgumentError do
textilize_without_paragraph("", :safe)
end
end
def test_textilize_without_paragraph_should_not_sanitize_safe_input
assert_equal("This is worded <strong>strongly</strong><script>code!</script>", textilize_without_paragraph("This is worded <strong>strongly</strong><script>code!</script>".html_safe))
end
def test_textilize_without_paragraph_with_hard_breaks
assert_equal("This is one scary world.<br />\n True.", textilize_without_paragraph("This is one scary world.\n True."))
end
def test_markdown_should_be_html_safe
assert markdown("We are using __Markdown__ now!").html_safe?
end
def test_markdown
assert_equal("<p>We are using <strong>Markdown</strong> now!</p>", markdown("We are using __Markdown__ now!"))
end
def test_markdown_with_blank
assert_equal("", markdown(""))
end
def test_markdown_with_flags
assert_equal("<p>This is worded <strong>strongly</strong></p>", markdown("This is worded <strong>strongly</strong>", :escape_html))
end
def test_markdown_should_sanitize_unsafe_input
assert_equal("<p>This is worded <strong>strongly</strong></p>", markdown("This is worded <strong>strongly</strong><script>code!</script>"))
end
def test_markdown_should_raise_error_if_safe_flag
assert_raise ArgumentError do
markdown("", :safe)
end
end
def test_markdown_should_not_sanitize_safe_input
assert_equal("<p>This is worded <strong>strongly</strong><script>code!</script></p>", markdown("This is worded <strong>strongly</strong><script>code!</script>".html_safe))
end
def test_markdown_with_hard_breaks
assert_equal("<p>This is one scary world.</p>\n\n<p>True.</p>", markdown("This is one scary world.\n\nTrue."))
end
end