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:
- 2701 Bytes
1 | require File.dirname(__FILE__) + '/../test_helper' |
2 | |
3 | class TopicTest < Test::Unit::TestCase |
4 | all_fixtures |
5 | |
6 | def test_save_should_update_post_id_for_posts_belonging_to_topic |
7 | # checking current forum_id's are in sync |
8 | topic = topics(:pdi) |
9 | post_forums = lambda do |
10 | topic.posts.each { |p| assert_equal p.forum_id, topic.forum_id } |
11 | end |
12 | post_forums.call |
13 | assert_equal forums(:rails).id, topic.forum_id |
14 | |
15 | # updating forum_id |
16 | topic.update_attribute :forum_id, forums(:comics).id |
17 | assert_equal forums(:comics).id, topic.reload.forum_id |
18 | post_forums.call |
19 | end |
20 | |
21 | def test_knows_last_post |
22 | assert_equal posts(:pdi_rebuttal), topics(:pdi).posts.last |
23 | end |
24 | |
25 | def test_should_require_title_user_and_forum |
26 | t=Topic.new |
27 | t.valid? |
28 | assert t.errors.on(:title) |
29 | assert t.errors.on(:user) |
30 | assert t.errors.on(:forum) |
31 | assert ! t.save |
32 | t.user = users(:aaron) |
33 | t.title = "happy life" |
34 | t.forum = forums(:rails) |
35 | assert t.save |
36 | assert_nil t.errors.on(:title) |
37 | assert_nil t.errors.on(:user) |
38 | assert_nil t.errors.on(:forum) |
39 | end |
40 | |
41 | def test_should_add_to_user_counter_cache |
42 | assert_difference Post, :count do |
43 | assert_difference users(:sam).posts, :count do |
44 | p = topics(:pdi).posts.build(:body => "I'll do it") |
45 | p.user = users(:sam) |
46 | p.save |
47 | end |
48 | end |
49 | end |
50 | |
51 | def test_should_create_topic |
52 | counts = lambda { [Topic.count, forums(:rails).topics_count] } |
53 | old = counts.call |
54 | t = forums(:rails).topics.build(:title => 'foo') |
55 | t.user = users(:aaron) |
56 | assert_valid t |
57 | t.save |
58 | assert_equal 0, t.sticky |
59 | [forums(:rails), users(:aaron)].each &:reload |
60 | assert_equal old.collect { |n| n + 1}, counts.call |
61 | end |
62 | |
63 | def test_should_delete_topic |
64 | counts = lambda { [Topic.count, Post.count, forums(:rails).topics_count, forums(:rails).posts_count, users(:sam).posts_count] } |
65 | old = counts.call |
66 | topics(:ponies).destroy |
67 | [forums(:rails), users(:sam)].each &:reload |
68 | assert_equal old.collect { |n| n - 1}, counts.call |
69 | end |
70 | |
71 | def test_hits |
72 | hits=topics(:pdi).views |
73 | topics(:pdi).hit! |
74 | topics(:pdi).hit! |
75 | assert_equal(hits+2, topics(:pdi).reload.hits) |
76 | assert_equal(topics(:pdi).hits, topics(:pdi).views) |
77 | end |
78 | |
79 | def test_replied_at_set |
80 | t=Topic.new |
81 | t.user=users(:aaron) |
82 | t.title = "happy life" |
83 | t.forum = forums(:rails) |
84 | assert t.save |
85 | assert_not_nil t.replied_at |
86 | assert t.replied_at <= Time.now.utc |
87 | assert_in_delta t.replied_at, Time.now.utc, 5.seconds |
88 | end |
89 | |
90 | def test_doesnt_change_replied_at_on_save |
91 | t=Topic.find(:first) |
92 | old=t.replied_at |
93 | assert t.save |
94 | assert_equal old, t.replied_at |
95 | end |
96 | |
97 | end |