Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 171
- Log:
Initial import of Beast 0.9 from downloaded Tarball. Beast is a Ruby
On Rails based forum application. The original tarball came from the
following location:http://s3.amazonaws.com/beast-forum/beast-0.9.tar.gz
The forum post which announced this version's availability was at:
http://beast.caboo.se/forums/1/topics/446
- Author:
- rool
- Date:
- Fri Mar 02 15:51:55 +0000 2007
- Size:
- 5733 Bytes
1 | require File.dirname(__FILE__) + '/../test_helper' |
2 | require 'topics_controller' |
3 | |
4 | # Re-raise errors caught by the controller. |
5 | class TopicsController; def rescue_action(e) raise e end; end |
6 | |
7 | class TopicsControllerTest < Test::Unit::TestCase |
8 | all_fixtures |
9 | |
10 | def setup |
11 | @controller = TopicsController.new |
12 | @request = ActionController::TestRequest.new |
13 | @response = ActionController::TestResponse.new |
14 | end |
15 | |
16 | def test_should_get_index |
17 | get :index, :forum_id => 1 |
18 | assert_redirected_to forum_path(1) |
19 | end |
20 | |
21 | def test_should_show_topic_as_rss |
22 | get :show, :forum_id => forums(:rails).id, :id => topics(:pdi).id, :format => 'rss' |
23 | assert_response :success |
24 | end |
25 | |
26 | def test_should_get_new |
27 | login_as :aaron |
28 | get :new, :forum_id => 1 |
29 | assert_response :success |
30 | end |
31 | |
32 | def test_sticky_and_locked_protected_from_non_admin |
33 | login_as :joe |
34 | assert ! users(:joe).admin? |
35 | assert ! users(:joe).moderator_of?(:rails) |
36 | post :create, :forum_id => forums(:rails).id, :topic => { :title => 'blah', :sticky => "1", :locked => "1", :body => 'foo' } |
37 | assert assigns(:topic) |
38 | assert ! assigns(:topic).sticky? |
39 | assert ! assigns(:topic).locked? |
40 | end |
41 | |
42 | def test_sticky_and_locked_allowed_to_moderator |
43 | login_as :sam |
44 | assert ! users(:sam).admin? |
45 | assert users(:sam).moderator_of?(forums(:rails)) |
46 | post :create, :forum_id => forums(:rails).id, :topic => { :title => 'blah', :sticky => "1", :locked => "1", :body => 'foo' } |
47 | assert assigns(:topic) |
48 | assert assigns(:topic).sticky? |
49 | assert assigns(:topic).locked? |
50 | end |
51 | |
52 | def test_should_allow_admin_to_sticky_and_lock |
53 | login_as :aaron |
54 | post :create, :forum_id => forums(:rails).id, :topic => { :title => 'blah2', :sticky => "1", :locked => "1", :body => 'foo' } |
55 | assert assigns(:topic).sticky? |
56 | assert assigns(:topic).locked? |
57 | end |
58 | |
59 | def test_should_create_topic |
60 | counts = lambda { [Topic.count, Post.count, forums(:rails).topics_count, forums(:rails).posts_count, users(:aaron).posts_count] } |
61 | old = counts.call |
62 | |
63 | login_as :aaron |
64 | post :create, :forum_id => forums(:rails).id, :topic => { :title => 'blah', :body => 'foo' } |
65 | assert assigns(:topic) |
66 | assert assigns(:post) |
67 | [forums(:rails), users(:aaron)].each &:reload |
68 | |
69 | assert_equal old.collect { |n| n + 1}, counts.call |
70 | end |
71 | |
72 | def test_should_delete_topic |
73 | counts = lambda { [Post.count, forums(:rails).topics_count, forums(:rails).posts_count] } |
74 | old = counts.call |
75 | |
76 | login_as :aaron |
77 | delete :destroy, :forum_id => forums(:rails).id, :id => topics(:ponies).id |
78 | [forums(:rails), users(:aaron)].each &:reload |
79 | |
80 | assert_equal old.collect { |n| n - 1}, counts.call |
81 | end |
82 | |
83 | def test_should_allow_moderator_to_delete_topic |
84 | assert_difference Topic, :count, -1 do |
85 | login_as :sam |
86 | delete :destroy, :forum_id => forums(:rails).id, :id => topics(:pdi).id |
87 | end |
88 | end |
89 | |
90 | def test_should_update_views_for_show |
91 | assert_difference topics(:pdi), :views do |
92 | get :show, :forum_id => forums(:rails).id, :id => topics(:pdi).id |
93 | assert_response :success |
94 | topics(:pdi).reload |
95 | end |
96 | end |
97 | |
98 | def test_should_not_update_views_for_show_via_rss |
99 | assert_difference topics(:pdi), :views, 0 do |
100 | get :show, :forum_id => forums(:rails).id, :id => topics(:pdi).id, :format => 'rss' |
101 | assert_response :success |
102 | topics(:pdi).reload |
103 | end |
104 | end |
105 | |
106 | def test_should_not_add_viewed_topic_to_session_on_show_rss |
107 | login_as :aaron |
108 | get :show, :forum_id => forums(:rails).id, :id => topics(:pdi).id, :format => 'rss' |
109 | assert_response :success |
110 | assert session[:topics].blank? |
111 | end |
112 | |
113 | def test_should_update_views_for_show_except_topic_author |
114 | login_as :aaron |
115 | views=topics(:pdi).views |
116 | get :show, :forum_id => forums(:rails).id, :id => topics(:pdi).id |
117 | assert_response :success |
118 | assert_equal views, topics(:pdi).reload.views |
119 | end |
120 | |
121 | def test_should_show_topic |
122 | get :show, :forum_id => forums(:rails).id, :id => topics(:pdi).id |
123 | assert_response :success |
124 | assert_equal topics(:pdi), assigns(:topic) |
125 | assert_models_equal [posts(:pdi), posts(:pdi_reply), posts(:pdi_rebuttal)], assigns(:posts) |
126 | end |
127 | |
128 | def test_should_show_other_post |
129 | get :show, :forum_id => forums(:rails).id, :id => topics(:ponies).id |
130 | assert_response :success |
131 | assert_equal topics(:ponies), assigns(:topic) |
132 | assert_models_equal [posts(:ponies)], assigns(:posts) |
133 | end |
134 | |
135 | def test_should_get_edit |
136 | login_as :aaron |
137 | get :edit, :forum_id => 1, :id => 1 |
138 | assert_response :success |
139 | end |
140 | |
141 | def test_should_update_own_post |
142 | login_as :sam |
143 | put :update, :forum_id => forums(:rails).id, :id => topics(:ponies).id, :topic => { } |
144 | assert_redirected_to topic_path(forums(:rails), assigns(:topic)) |
145 | end |
146 | |
147 | def test_should_not_update_user_id_of_own_post |
148 | login_as :sam |
149 | put :update, :forum_id => forums(:rails).id, :id => topics(:ponies).id, :topic => { :user_id => 32 } |
150 | assert_redirected_to topic_path(forums(:rails), assigns(:topic)) |
151 | assert_equal users(:sam).id, posts(:ponies).reload.user_id |
152 | end |
153 | |
154 | def test_should_not_update_other_post |
155 | login_as :sam |
156 | put :update, :forum_id => forums(:comics).id, :id => topics(:galactus).id, :topic => { } |
157 | assert_redirected_to login_path |
158 | end |
159 | |
160 | def test_should_update_other_post_as_moderator |
161 | login_as :sam |
162 | put :update, :forum_id => forums(:rails).id, :id => topics(:pdi).id, :topic => { } |
163 | assert_redirected_to topic_path(forums(:rails), assigns(:topic)) |
164 | end |
165 | |
166 | def test_should_update_other_post_as_admin |
167 | login_as :aaron |
168 | put :update, :forum_id => forums(:rails).id, :id => topics(:ponies), :topic => { } |
169 | assert_redirected_to topic_path(forums(:rails), assigns(:topic)) |
170 | end |
171 | end |