Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 7
- Log:
Initial import of RForum 0.2 sources from a downloaded Tarball.
RForum is a Ruby On Rails based forum and mail gateway service.
- Author:
- adh
- Date:
- Sat Jul 22 18:43:13 +0100 2006
- Size:
- 2455 Bytes
- Properties:
- Property svn:executable is set
1 | #!/bin/env ruby |
2 | |
3 | require File.dirname(__FILE__) + '/../test_helper' |
4 | require 'rexml/document' |
5 | require 'forum_controller' |
6 | |
7 | # Raise errors beyond the default web-based presentation |
8 | class ForumController; def rescue_action(e) raise e end; end |
9 | |
10 | class ForumControllerTest < Test::Unit::TestCase |
11 | include RForum::Localization |
12 | |
13 | def setup |
14 | setup_controller_test |
15 | setup_forum_fixture |
16 | end |
17 | |
18 | def test_index |
19 | r = process('index') |
20 | |
21 | assert_redirected_to '/' |
22 | end |
23 | |
24 | def test_list |
25 | r = process('list') |
26 | |
27 | assert_success |
28 | xml = REXML::Document.new(r.body) |
29 | # response body should contain URLs to both fixture forums |
30 | forum_hrefs = REXML::XPath.match(xml, "//td[@class='name-description']/a") |
31 | forum_urls = forum_hrefs.map {|element| element.attribute('href').value }.sort |
32 | assert_equal ['/forum/1', '/forum/2'], forum_urls |
33 | end |
34 | |
35 | def test_forum |
36 | r = process('forum', {'id' => 1}, {:user_id => 1}) |
37 | |
38 | assert_success |
39 | xml = REXML::Document.new(r.body) |
40 | topics = REXML::XPath.match(xml, "//td[@class='subject']/a") |
41 | topic_urls = topics.map {|element| element.attribute('href').value }.sort |
42 | assert_equal ['/topic/1#new', '/topic/2#new'], topic_urls |
43 | end |
44 | |
45 | def test_forum_new_posts |
46 | r = process('forum', {'id' => 1}, {:user_id => 1}) |
47 | |
48 | assert_success |
49 | xml = REXML::Document.new(r.body) |
50 | |
51 | new_topics = REXML::XPath.match(xml, "//tr[contains(@class,'new-posts')]/td[@class='subject']/a") |
52 | new_topic_urls = new_topics.map {|element| element.attribute('href').value }.sort |
53 | assert_equal ['/topic/2#new'], new_topic_urls |
54 | end |
55 | |
56 | def test_forum_no_topics |
57 | Topic.delete_all('forum_id = 1'); |
58 | |
59 | r = process('forum', 'id' => 1) |
60 | |
61 | assert r.body.include?(l(:forum_is_empty)) |
62 | end |
63 | |
64 | def test_deleted_topic_not_displayed |
65 | Topic.find(1).hide |
66 | r = process('forum', 'id' => 1) |
67 | |
68 | displayed_topics = r.template_objects['topics'].collect { |t| t.id } |
69 | assert_equal [2], displayed_topics |
70 | end |
71 | |
72 | def test_tag |
73 | Topic.find(1).tags << Tag.find_by_name('first') |
74 | r = process('forum', {'id' => 1, 'tag' => 'first'}, {:user_id => 1}) |
75 | |
76 | displayed_topics = r.template_objects['topics'].collect { |t| t.id } |
77 | assert_equal [1], displayed_topics |
78 | end |
79 | |
80 | def test_last_post_by_guest_without_name |
81 | Post.create( :guest_name => '', :subject => 'subject foo', :text => 'content', :topic_id => '1' ) |
82 | topic = Topic.find(1) |
83 | assert_equal "Guest", topic.last_post_author |
84 | end |
85 | |
86 | end |