Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 10
- Log:
Checking in HEAD from RForum's SVN of 22-Jul-2006, 8pm (revision 906).
- Author:
- adh
- Date:
- Sat Jul 22 20:02:44 +0100 2006
- Size:
- 3215 Bytes
- Properties:
- Property svn:executable is set
1 | #!/bin/env ruby |
2 | |
3 | require File.dirname(__FILE__) + '/../test_helper' |
4 | |
5 | class ForumTest < Test::Unit::TestCase |
6 | fixtures 'forums', 'posts', 'topics', 'tags', 'topics_tags' |
7 | |
8 | def setup |
9 | @forum = Forum.find(1) |
10 | end |
11 | |
12 | def test_get_topics_for_list |
13 | assert_equal [2], @forum.get_topics_for_list(0..0).map{ |t| t.id } |
14 | assert_equal [2, 1], @forum.get_topics_for_list(0..1).map{ |t| t.id } |
15 | end |
16 | |
17 | def test_get_topics_for_list_tag |
18 | tag = Tag.find(1) |
19 | Topic.find(1).tags << tag |
20 | |
21 | assert_equal [1], @forum.get_topics_for_list(0..1, tag.name).map{ |t| t.id } |
22 | assert_equal [2, 1], @forum.get_topics_for_list(0..1).map{ |t| t.id } |
23 | assert_equal [], @forum.get_topics_for_list(0..1, 'foobar').map{ |t| t.id } |
24 | |
25 | Topic.find(2).tags << tag |
26 | assert_equal [2, 1], @forum.get_topics_for_list(0..1, tag.name).map{ |t| t.id } |
27 | assert_equal [2], @forum.get_topics_for_list(0..0, tag.name).map{ |t| t.id } |
28 | end |
29 | |
30 | def test_get_topics_for_list_hidden |
31 | Topic.find(1).hide |
32 | |
33 | assert_equal [1, 2], @forum.get_topics_for_list(0..1, nil, true).map{ |t| t.id } |
34 | assert_equal [2], @forum.get_topics_for_list(0..1, nil, false).map{ |t| t.id } |
35 | end |
36 | |
37 | def test_get_topics_for_list_tag_hidden |
38 | tag = Tag.find(1) |
39 | Topic.find(1).tags << tag |
40 | Topic.find(1).hide |
41 | |
42 | assert_equal [1], @forum.get_topics_for_list(0..1, tag.name, true).map{ |t| t.id } |
43 | assert_equal [], @forum.get_topics_for_list(0..1, tag.name, false).map{ |t| t.id } |
44 | end |
45 | |
46 | def test_destroy |
47 | assert_nothing_raised { @forum.destroy } |
48 | end |
49 | |
50 | def test_add_post_new_topic |
51 | post = prototype(Post, 'subject' => 'New Topic', 'user_id' => 1) |
52 | |
53 | @forum.add_post(post) |
54 | |
55 | assert_not_equal 1, post.topic_id |
56 | assert_equal 1, post.topic.posts.size |
57 | assert_equal post.subject, post.topic.subject |
58 | assert_equal post.created_at.to_i, post.topic.last_post_created_at.to_i |
59 | assert_equal post.user_id, post.topic.last_post_user_id |
60 | assert_equal post.get_display_name, post.topic.last_post_author |
61 | assert_nested_set_well_formed(post.topic_id) |
62 | end |
63 | |
64 | def test_nntp_grouplist |
65 | list = Forum.nntp_grouplist |
66 | assert_equal ["mikrocontroller.avr #{max_nntpid} 1 y", "mikrocontroller.msp430 2 1 y"], list |
67 | end |
68 | |
69 | def test_get_next_free_nntpid |
70 | assert_equal max_nntpid + 1, @forum.get_next_free_nntpid |
71 | end |
72 | |
73 | def test_get_next_free_nntpid_new_forum |
74 | f = Forum.create(prototype_params(Forum)) |
75 | assert_equal 1, f.get_next_free_nntpid |
76 | end |
77 | |
78 | def test_find_by_groupname |
79 | f = Forum.find_by_groupname "mikrocontroller.avr" |
80 | |
81 | assert_equal 1, f.id |
82 | end |
83 | |
84 | def max_nntpid |
85 | # this assumes that the message with biggest nntpid belongs to forum #1 |
86 | ActiveRecord::Base.connection.select_one( |
87 | 'SELECT MAX(NNTPID) as max_nntpid FROM posts')['max_nntpid'].to_i |
88 | end |
89 | |
90 | def test_get_topics_num |
91 | f = Forum.find(2) |
92 | n = f.get_topics_num |
93 | assert_equal 1 , n |
94 | end |
95 | |
96 | def test_get_posts_num |
97 | f = Forum.find(2) |
98 | n = f.get_posts_num |
99 | assert_equal 2 , n |
100 | end |
101 | |
102 | def test_get_last_post |
103 | Topic.find_all.each { |t| t.update_last_post_data; t.save } |
104 | f = Forum.find(1) |
105 | p = f.get_last_post |
106 | assert_equal 11, p.id |
107 | end |
108 | end |