wiki.pl: Port some fixes from upstream
[Orgmuse.git] / t / despam.t
blobb8d6b1513fca96a737265d0329f249e6619dd84c
1 # Copyright (C) 2006, 2007  Alex Schroeder <alex@emacswiki.org>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the
15 #    Free Software Foundation, Inc.
16 #    59 Temple Place, Suite 330
17 #    Boston, MA 02111-1307 USA
19 require 't/test.pl';
20 package OddMuse;
21 use Test::More tests => 13;
23 clear_pages();
25 add_module('despam.pl');
27 update_page('HilariousPage', "Ordinary text.");
28 update_page('HilariousPage', "Hilarious text.");
29 update_page('HilariousPage', "Spam from http://example.com.");
31 update_page('NoPage', "Spam from http://example.com.");
33 update_page('OrdinaryPage', "Spam from http://example.com.");
34 update_page('OrdinaryPage', "Ordinary text.");
36 update_page('ExpiredPage', "Spam from http://example.com.");
37 update_page('ExpiredPage', "More spam from http://example.com.");
38 update_page('ExpiredPage', "Still more spam from http://example.com.");
40 update_page('BannedContent', " example\\.com\n", 'required', 0, 1);
42 unlink("$DataDir/keep/E/ExpiredPage/1.kp")
43   or die "Cannot delete kept revision: $!";
45 my $page = get_page('action=spam');
46 test_page($page, 'HilariousPage', 'NoPage', 'ExpiredPage');
47 test_page_negative($page, 'OrdinaryPage');
49 test_page(get_page('action=despam'), 'HilariousPage.*Revert to revision 2',
50           'NoPage.*Marked as DeletedPage', 'OrdinaryPage',
51           'ExpiredPage.*Cannot find unspammed revision');
53 test_page(get_page('ExpiredPage'), 'Still more spam');
54 test_page(get_page('OrdinaryPage'), 'Ordinary text');
55 test_page(get_page('NoPage'), 'DeletedPage');
56 test_page(get_page('HilariousPage'), 'Hilarious text');
57 test_page(get_page('BannedContent'), 'example\\\.com');