additional functional tests, some controller fixes

This commit is contained in:
albert
2010-12-01 18:50:04 -05:00
parent 39dd2e277a
commit 976a25a6c6
19 changed files with 185 additions and 27 deletions

View File

@@ -1,8 +1,36 @@
require 'test_helper'
class CommentsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
context "A comments controller" do
setup do
CurrentUser.user = Factory.create(:user)
CurrentUser.ip_addr = "127.0.0.1"
@comment = Factory.create(:comment)
@user = Factory.create(:moderator_user)
end
teardown do
CurrentUser.user = nil
CurrentUser.ip_addr = nil
end
should "render the index page" do
get :index
assert_response :success
end
should "update a comment" do
post :update, {:id => @comment.id, :comment => {:body => "abc"}}, {:user_id => @comment.creator_id}
assert_redirected_to comment_path(@comment)
end
should "create a comment" do
p = Factory.create(:post)
assert_difference("Comment.count", 1) do
post :create, {:comment => Factory.attributes_for(:comment, :post_id => p.id)}, {:user_id => @user.id}
end
comment = Comment.last
assert_redirected_to post_path(comment.post)
end
end
end