deleting a forum topic should delete its posts
This commit is contained in:
@@ -74,7 +74,16 @@ class ForumTopicsControllerTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
context "destroy action" do
|
||||
setup do
|
||||
@post = Factory.create(:forum_post, :topic_id => @forum_topic.id)
|
||||
end
|
||||
|
||||
should "destroy the topic and any associated posts" do
|
||||
assert_difference(["ForumPost.count", "ForumTopic.count"], -1) do
|
||||
post :destroy, {:id => @forum_topic.id}, {:user_id => @user.id}
|
||||
end
|
||||
assert_redirected_to(forum_topics_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -42,5 +42,19 @@ class ForumTopicTest < ActiveSupport::TestCase
|
||||
assert_equal(@second_user.id, @topic.updater_id)
|
||||
end
|
||||
end
|
||||
|
||||
context "with multiple posts that has been deleted" do
|
||||
setup do
|
||||
5.times do
|
||||
Factory.create(:forum_post, :topic_id => @topic.id)
|
||||
end
|
||||
end
|
||||
|
||||
should "delete any associated posts" do
|
||||
assert_difference("ForumPost.count", -5) do
|
||||
@topic.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user