fixed tests
This commit is contained in:
@@ -44,7 +44,14 @@ class ForumTopicsController < ApplicationController
|
||||
def destroy
|
||||
@forum_topic = ForumTopic.find(params[:id])
|
||||
check_privilege(@forum_topic)
|
||||
@forum_topic.destroy
|
||||
@forum_topic.update_attribute(:is_deleted, true)
|
||||
respond_with(@forum_topic)
|
||||
end
|
||||
|
||||
def undelete
|
||||
@forum_topic = ForumTopic.find(params[:id])
|
||||
check_privilege(@forum_topic)
|
||||
@forum_topic.update_attribute(:is_deleted, false)
|
||||
respond_with(@forum_topic)
|
||||
end
|
||||
|
||||
|
||||
@@ -76,10 +76,23 @@ class ForumPostsControllerTest < ActionController::TestCase
|
||||
|
||||
context "destroy action" do
|
||||
should "destroy the posts" do
|
||||
assert_difference("ForumPost.count", -1) do
|
||||
post :destroy, {:id => @forum_post.id}, {:user_id => @user.id}
|
||||
end
|
||||
assert_redirected_to(forum_posts_path)
|
||||
post :destroy, {:id => @forum_post.id}, {:user_id => @user.id}
|
||||
assert_redirected_to(forum_post_path(@forum_post))
|
||||
@forum_post.reload
|
||||
assert_equal(true, @forum_post.is_deleted?)
|
||||
end
|
||||
end
|
||||
|
||||
context "undelete action" do
|
||||
setup do
|
||||
@forum_post.update_attribute(:is_deleted, true)
|
||||
end
|
||||
|
||||
should "restore the post" do
|
||||
post :undelete, {:id => @forum_post.id}, {:user_id => @user.id}
|
||||
assert_redirected_to(forum_post_path(@forum_post))
|
||||
@forum_post.reload
|
||||
assert_equal(false, @forum_post.is_deleted?)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -79,10 +79,23 @@ class ForumTopicsControllerTest < ActionController::TestCase
|
||||
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)
|
||||
post :destroy, {:id => @forum_topic.id}, {:user_id => @user.id}
|
||||
assert_redirected_to(forum_topic_path(@forum_topic))
|
||||
@forum_topic.reload
|
||||
assert_equal(true, @forum_topic.is_deleted?)
|
||||
end
|
||||
end
|
||||
|
||||
context "undelete action" do
|
||||
setup do
|
||||
@forum_topic.update_attribute(:is_deleted, true)
|
||||
end
|
||||
|
||||
should "restore the topic" do
|
||||
post :undelete, {:id => @forum_topic.id}, {:user_id => @user.id}
|
||||
assert_redirected_to(forum_topic_path(@forum_topic))
|
||||
@forum_topic.reload
|
||||
assert_equal(false, @forum_topic.is_deleted?)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user