Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 71
- Log:
Start of upgrade to Typo 4.0.0, the latest stable release since
2.6.0. Note test/mocks/themes/azure changes from a file to a
directory, so the file has been removed in this revision and
the directory will be added in the next revision.
- Author:
- adh
- Date:
- Mon Aug 07 22:18:11 +0100 2006
- Size:
- 3068 Bytes
1 | require File.dirname(__FILE__) + '/../test_helper' |
2 | |
3 | require 'dns_mock' |
4 | |
5 | class CommentTest < Test::Unit::TestCase |
6 | fixtures :contents, :blacklist_patterns, :text_filters, :blogs |
7 | |
8 | def test_save_regular |
9 | assert contents(:comment2).save |
10 | assert_equal "http://www.google.com", contents(:comment2).url |
11 | end |
12 | |
13 | def test_save_spam |
14 | assert contents(:spam_comment).save |
15 | assert_equal "http://fakeurl.com", contents(:spam_comment).url |
16 | end |
17 | |
18 | def test_create_comment |
19 | c = Comment.new |
20 | c.author = 'Bob' |
21 | c.article_id = 1 |
22 | c.body = 'nice post' |
23 | c.ip = '1.2.3.4' |
24 | |
25 | assert c.save |
26 | assert c.guid.size > 15 |
27 | end |
28 | |
29 | def test_reject_spam_rbl |
30 | c = Comment.new |
31 | c.author = "Spammer" |
32 | c.body = %{This is just some random text. <a href="http://chinaaircatering.com">without any senses.</a>. Please disregard.} |
33 | c.url = "http://buy-computer.us" |
34 | c.ip = "212.42.230.206" |
35 | |
36 | assert_equal true, c.is_spam? |
37 | end |
38 | |
39 | def test_not_spam_but_rbl_lookup_succeeds |
40 | c = Comment.new |
41 | c.author = "Not a Spammer" |
42 | c.body = "Useful commentary!" |
43 | c.url = "http://www.bofh.org.uk" |
44 | c.ip = "10.10.10.10" |
45 | |
46 | assert_equal false, c.is_spam? |
47 | end |
48 | |
49 | def test_reject_spam_pattern |
50 | c = Comment.new |
51 | c.author = "Another Spammer" |
52 | c.body = "Texas hold-em poker crap" |
53 | c.url = "http://texas.hold-em.us" |
54 | |
55 | assert_equal true, c.is_spam? |
56 | end |
57 | |
58 | def test_reject_spam_uri_limit |
59 | c = Comment.new |
60 | c.author = "Yet Another Spammer" |
61 | c.body = %{ <a href="http://www.one.com/">one</a> <a href="http://www.two.com/">two</a> <a href="http://www.three.com/">three</a> <a href="http://www.four.com/">four</a> } |
62 | c.url = "http://www.uri-limit.com" |
63 | c.ip = "123.123.123.123" |
64 | |
65 | assert_equal true, c.is_spam? |
66 | end |
67 | |
68 | def test_reject_article_age |
69 | c = Comment.new |
70 | c.author = "Old Spammer" |
71 | c.body = "Old trackback body" |
72 | c.article = contents(:inactive_article) |
73 | |
74 | assert ! c.save |
75 | assert c.errors.invalid?('article_id') |
76 | |
77 | c.article = @article1 |
78 | |
79 | assert c.save |
80 | assert c.errors.empty? |
81 | end |
82 | |
83 | def test_modify_old_comment |
84 | c = contents(:inactive_article).comments.first |
85 | c.body = 'Comment body <em>italic</em> <strong>bold</strong>' |
86 | assert c.save |
87 | assert c.errors.empty? |
88 | end |
89 | |
90 | def test_article_relation |
91 | assert_equal true, contents(:comment2).has_article? |
92 | assert_equal 1, contents(:comment2).article.id |
93 | end |
94 | |
95 | def test_xss_rejection |
96 | c = Comment.new |
97 | c.body = "Test foo <script>do_evil();</script>" |
98 | c.author = 'Bob' |
99 | c.article_id = 1 |
100 | |
101 | # Test each filter to make sure that we don't allow scripts through. |
102 | # Yes, this is ugly. |
103 | ['','textile','markdown','smartypants','markdown smartypants'].each do |filter| |
104 | this_blog.comment_text_filter = filter |
105 | |
106 | assert c.save |
107 | assert c.errors.empty? |
108 | |
109 | assert c.body_html !~ /<script>/ |
110 | end |
111 | end |
112 | |
113 | def test_withdraw |
114 | c = Comment.find(contents(:comment2).id) |
115 | assert c.withdraw! |
116 | assert ! c.published? |
117 | assert c.reload |
118 | assert ! c.published? |
119 | end |
120 | end |