fixed comment vote functional test

This commit is contained in:
albert
2011-04-01 19:01:17 -04:00
parent e7748e1fc9
commit cbd877d020
43 changed files with 135 additions and 20369 deletions

View File

@@ -3,10 +3,9 @@ require 'test_helper'
class CommentVotesControllerTest < ActionController::TestCase
context "A comment votes controller" do
setup do
CurrentUser.user = Factory.create(:user)
CurrentUser.user = @user = Factory.create(:user)
CurrentUser.ip_addr = "127.0.0.1"
@comment = Factory.create(:comment)
@user = Factory.create(:user)
end
teardown do
@@ -16,9 +15,15 @@ class CommentVotesControllerTest < ActionController::TestCase
should "create a vote" do
assert_difference("CommentVote.count", 1) do
post :create, {:format => "js", :comment_id => @comment.id}, {:user_id => @user.id}
post :create, {:format => "js", :comment_id => @comment.id, :score => 1}, {:user_id => @user.id}
assert_response :success
end
end
should "fail silently on errors" do
Factory.create(:comment_vote, :comment => @comment)
post :create, {:format => "js", :comment_id => @comment.id, :score => 1}, {:user_id => @user.id}
assert_response :error
end
end
end

View File

@@ -5,7 +5,8 @@ class CommentsControllerTest < ActionController::TestCase
setup do
CurrentUser.user = Factory.create(:user)
CurrentUser.ip_addr = "127.0.0.1"
@comment = Factory.create(:comment)
@post = Factory.create(:post)
@comment = Factory.create(:comment, :post => @post)
@user = Factory.create(:moderator_user)
end
@@ -29,15 +30,11 @@ class CommentsControllerTest < ActionController::TestCase
context "update action" do
should "update the comment" do
post :update, {:id => @comment.id, :comment => {:body => "abc"}}, {:user_id => @comment.creator_id}
assert_redirected_to comment_path(@comment)
assert_redirected_to post_path(@comment.post)
end
end
context "create action"do
setup do
@post = Factory.create(:post)
end
should "create a comment" do
assert_difference("Comment.count", 1) do
post :create, {:comment => Factory.attributes_for(:comment, :post_id => @post.id)}, {:user_id => @user.id}

View File

@@ -35,7 +35,7 @@ class FavoritesControllerTest < ActionController::TestCase
should "create a favorite for the current user" do
assert_difference("Favorite.count(#{@user.id})", 1) do
post :create, {:id => @post.id}, {:user_id => @user.id}
post :create, {:format => "js", :id => @post.id}, {:user_id => @user.id}
end
end
end
@@ -51,7 +51,7 @@ class FavoritesControllerTest < ActionController::TestCase
should "remove the favorite from the current user" do
assert_difference("Favorite.count(#{@user.id})", -1) do
post :destroy, {:id => @post.id}, {:user_id => @user.id}
post :destroy, {:format => "js", :id => @post.id}, {:user_id => @user.id}
end
end
end

View File

@@ -70,7 +70,7 @@ class ForumPostsControllerTest < ActionController::TestCase
end
forum_post = ForumPost.last
assert_redirected_to(forum_post_path(forum_post))
assert_redirected_to(forum_topic_path(@forum_topic, :page => 1))
end
end