Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 15
- Log:
Attempt to update Typo to a Typo SVN HEAD release from around the
time the prototype installation was set up on the RISC OS Open Limited
web site. Timestamps place this at 04-Jul so a revision from 05-Jul or
earlier was pulled and copied over the 2.6.0 tarball stable code.
- Author:
- adh
- Date:
- Sat Jul 22 23:27:35 +0100 2006
- Size:
- 3024 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 ! c.save |
37 | assert c.errors.invalid?('body') |
38 | assert c.errors.invalid?('url') |
39 | assert c.errors.invalid?('ip') |
40 | end |
41 | |
42 | def test_not_spam_but_rbl_lookup_succeeds |
43 | c = Comment.new |
44 | c.author = "Not a Spammer" |
45 | c.body = "Useful commentary!" |
46 | c.url = "http://www.bofh.org.uk" |
47 | c.ip = "10.10.10.10" |
48 | |
49 | assert c.save |
50 | end |
51 | |
52 | def test_reject_spam_pattern |
53 | c = Comment.new |
54 | c.author = "Another Spammer" |
55 | c.body = "Texas hold-em poker crap" |
56 | c.url = "http://texas.hold-em.us" |
57 | |
58 | assert ! c.save |
59 | assert c.errors.invalid?('body') |
60 | end |
61 | |
62 | def test_reject_spam_uri_limit |
63 | c = Comment.new |
64 | c.author = "Yet Another Spammer" |
65 | 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> } |
66 | c.url = "http://www.uri-limit.com" |
67 | c.ip = "123.123.123.123" |
68 | |
69 | assert ! c.save |
70 | assert c.errors.invalid?('body') |
71 | end |
72 | |
73 | def test_reject_article_age |
74 | c = Comment.new |
75 | c.author = "Old Spammer" |
76 | c.body = "Old trackback body" |
77 | c.article = contents(:inactive_article) |
78 | |
79 | assert ! c.save |
80 | assert c.errors.invalid?('article_id') |
81 | |
82 | c.article = @article1 |
83 | |
84 | assert c.save |
85 | assert c.errors.empty? |
86 | end |
87 | |
88 | def test_modify_old_comment |
89 | c = contents(:inactive_article).comments.first |
90 | c.body = 'Comment body <em>italic</em> <strong>bold</strong>' |
91 | assert c.save |
92 | assert c.errors.empty? |
93 | end |
94 | |
95 | def test_article_relation |
96 | assert_equal true, contents(:comment2).has_article? |
97 | assert_equal 1, contents(:comment2).article.id |
98 | end |
99 | |
100 | def test_xss_rejection |
101 | c = Comment.new |
102 | c.body = "Test foo <script>do_evil();</script>" |
103 | c.author = 'Bob' |
104 | c.article_id = 1 |
105 | |
106 | # Test each filter to make sure that we don't allow scripts through. |
107 | # Yes, this is ugly. |
108 | ['','textile','markdown','smartypants','markdown smartypants'].each do |filter| |
109 | this_blog.comment_text_filter = filter |
110 | |
111 | assert c.save |
112 | assert c.errors.empty? |
113 | |
114 | assert c.body_html !~ /<script>/ |
115 | end |
116 | end |
117 | end |