despam.t 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # Copyright (C) 2006, 2007 Alex Schroeder <alex@emacswiki.org>
  2. #
  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.
  7. #
  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.
  12. #
  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
  18. require 't/test.pl';
  19. package OddMuse;
  20. use Test::More tests => 13;
  21. add_module('despam.pl');
  22. update_page('HilariousPage', "Ordinary text.");
  23. update_page('HilariousPage', "Hilarious text.");
  24. update_page('HilariousPage', "Spam from http://example.com.");
  25. update_page('NoPage', "Spam from http://example.com.");
  26. update_page('OrdinaryPage', "Spam from http://example.com.");
  27. update_page('OrdinaryPage', "Ordinary text.");
  28. update_page('ExpiredPage', "Spam from http://example.com.");
  29. update_page('ExpiredPage', "More spam from http://example.com.");
  30. update_page('ExpiredPage', "Still more spam from http://example.com.");
  31. update_page('BannedContent', " example\\.com\n", 'required', 0, 1);
  32. unlink("$DataDir/keep/ExpiredPage/1.kp")
  33. or die "Cannot delete kept revision: $!";
  34. my $page = get_page('action=spam');
  35. test_page($page, 'HilariousPage', 'NoPage', 'ExpiredPage');
  36. test_page_negative($page, 'OrdinaryPage');
  37. test_page(get_page('action=despam'), 'HilariousPage.*Revert to revision 2',
  38. 'NoPage.*Marked as DeletedPage', 'OrdinaryPage',
  39. 'ExpiredPage.*Cannot find unspammed revision');
  40. test_page(get_page('ExpiredPage'), 'Still more spam');
  41. test_page(get_page('OrdinaryPage'), 'Ordinary text');
  42. test_page(get_page('NoPage'), 'DeletedPage');
  43. test_page(get_page('HilariousPage'), 'Hilarious text');
  44. test_page(get_page('BannedContent'), 'example\\\.com');