Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 173
- Log:
Updated to latest release of Beast according to the "getting started with
Beast" guide at:http://beast.caboo.se/forums/1/topics/381
This check-in includes frozen Edge Rails and has the beginnings of
configuration for the ROOL site included.
- Author:
- rool
- Date:
- Fri Mar 02 15:59:12 +0000 2007
- Size:
- 2791 Bytes
1 | require File.dirname(__FILE__) + '/../test_helper' |
2 | |
3 | class PostTest < Test::Unit::TestCase |
4 | all_fixtures |
5 | |
6 | def test_should_select_posts |
7 | assert_equal [posts(:pdi), posts(:pdi_reply), posts(:pdi_rebuttal)], topics(:pdi).posts |
8 | end |
9 | |
10 | def test_should_find_topic |
11 | assert_equal topics(:pdi), posts(:pdi_reply).topic |
12 | end |
13 | |
14 | def test_should_require_body_for_post |
15 | p = topics(:pdi).posts.build |
16 | p.valid? |
17 | assert p.errors.on(:body) |
18 | end |
19 | |
20 | def test_should_create_reply |
21 | counts = lambda { [Post.count, forums(:rails).posts_count, users(:aaron).posts_count, topics(:pdi).posts_count] } |
22 | equal = lambda { [forums(:rails).topics_count] } |
23 | old_counts = counts.call |
24 | old_equal = equal.call |
25 | |
26 | p = create_post topics(:pdi), :body => 'blah' |
27 | assert_valid p |
28 | |
29 | [forums(:rails), users(:aaron), topics(:pdi)].each &:reload |
30 | |
31 | assert_equal old_counts.collect { |n| n + 1}, counts.call |
32 | assert_equal old_equal, equal.call |
33 | end |
34 | |
35 | def test_should_update_cached_data |
36 | p = create_post topics(:pdi), :body => 'ok, ill get right on it' |
37 | assert_valid p |
38 | topics(:pdi).reload |
39 | assert_equal p.id, topics(:pdi).last_post_id |
40 | assert_equal p.user_id, topics(:pdi).replied_by |
41 | assert_equal p.created_at.to_i, topics(:pdi).replied_at.to_i |
42 | end |
43 | |
44 | def test_should_delete_last_post_and_fix_topic_cached_data |
45 | posts(:pdi_rebuttal).destroy |
46 | assert_equal posts(:pdi_reply).id, topics(:pdi).last_post_id |
47 | assert_equal posts(:pdi_reply).user_id, topics(:pdi).replied_by |
48 | assert_equal posts(:pdi_reply).created_at.to_i, topics(:pdi).replied_at.to_i |
49 | end |
50 | |
51 | def test_should_create_reply_and_set_forum_from_topic |
52 | p = create_post topics(:pdi), :body => 'blah' |
53 | assert_equal topics(:pdi).forum_id, p.forum_id |
54 | end |
55 | |
56 | def test_should_delete_reply |
57 | counts = lambda { [Post.count, forums(:rails).posts_count, users(:sam).posts_count, topics(:pdi).posts_count] } |
58 | equal = lambda { [forums(:rails).topics_count] } |
59 | old_counts = counts.call |
60 | old_equal = equal.call |
61 | posts(:pdi_reply).destroy |
62 | [forums(:rails), users(:sam), topics(:pdi)].each &:reload |
63 | assert_equal old_counts.collect { |n| n - 1}, counts.call |
64 | assert_equal old_equal, equal.call |
65 | end |
66 | |
67 | def test_should_edit_own_post |
68 | assert posts(:shield).editable_by?(users(:sam)) |
69 | end |
70 | |
71 | def test_should_edit_post_as_admin |
72 | assert posts(:shield).editable_by?(users(:aaron)) |
73 | end |
74 | |
75 | def test_should_edit_post_as_moderator |
76 | assert posts(:pdi).editable_by?(users(:sam)) |
77 | end |
78 | |
79 | def test_should_not_edit_post_in_own_topic |
80 | assert !posts(:shield_reply).editable_by?(users(:sam)) |
81 | end |
82 | |
83 | protected |
84 | def create_post(topic, options = {}) |
85 | returning topic.posts.build(options) do |p| |
86 | p.user = users(:aaron) |
87 | p.save |
88 | end |
89 | end |
90 | end |