public
Description: The open source social networking platform in Ruby on Rails from the author of RailsSpace
Homepage: http://insoshi.com
Clone URL: git://github.com/insoshi/insoshi.git
Admin forum topic deletion and tests
Michael Hartl (author)
Thu May 01 13:11:05 -0700 2008
commit  3fc2bb519469fd6562f84acb765399beb4060a9b
tree    9c7e4569ad0daa1d23717172ef742a16a96dc79e
parent  e9902ec9df9fb48a99a5aeea1bb0de19fd5373e0
...
21
22
23
24
 
25
26
27
...
21
22
23
 
24
25
26
27
0
@@ -21,7 +21,7 @@ class ForumPost < Post
0
   belongs_to :topic, :counter_cache => true
0
   belongs_to :person, :counter_cache => true
0
   
0
- validates_presence_of :body, :topic, :person
0
+ validates_presence_of :body, :person
0
   validates_length_of :body, :maximum => MAX_TEXT_LENGTH
0
   
0
   after_create :log_activity
...
18
19
20
21
 
22
23
 
 
 
 
24
25
26
...
18
19
20
 
21
22
23
24
25
26
27
28
29
30
0
@@ -18,9 +18,13 @@ describe Activity do
0
     destroy_should_remove_activity(@comment)
0
   end
0
   
0
- it "should delete a topic activity along with its parent item" do
0
+ it "should delete topic & post activities along with the parent items" do
0
     @topic = Topic.create(:name => "A topic", :forum => forums(:one),
0
                           :person => @person)
0
+ @topic.posts.create(:body => "body", :person => @person)
0
+ @topic.posts.each do |post|
0
+ destroy_should_remove_activity(post)
0
+ end
0
     destroy_should_remove_activity(@topic)
0
   end
0
   
...
3
4
5
 
6
7
 
8
9
10
...
22
23
24
25
 
 
 
 
 
 
 
 
 
26
27
28
...
3
4
5
6
7
 
8
9
10
11
...
23
24
25
 
26
27
28
29
30
31
32
33
34
35
36
37
0
@@ -3,8 +3,9 @@ require File.dirname(__FILE__) + '/../spec_helper'
0
 describe Topic do
0
   
0
   before(:each) do
0
+ @person = people(:quentin)
0
     @topic = Topic.new(:name => "A topic", :forum => forums(:one),
0
- :person => people(:quentin))
0
+ :person => @person)
0
   end
0
 
0
   it "should be valid" do
0
@@ -22,7 +23,15 @@ describe Topic do
0
   end
0
   
0
   it "should have many posts" do
0
- Topic.new.posts.should be_a_kind_of(Array)
0
+ @topic.posts.should be_a_kind_of(Array)
0
+ end
0
+
0
+ it "should destroy associated posts" do
0
+ @topic.save!
0
+ @topic.posts.create(:body => "body", :person => @person)
0
+ # See the custom model matcher DestroyAssociated, located in
0
+ # spec/matchers/custom_model_matchers.rb.
0
+ @topic.should destroy_associated(:posts)
0
   end
0
   
0
   it "should belong to a person" do

Comments

    No one has commented yet.