fixed comment vote functional test
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
Factory.define(:comment_vote) do |f|
|
||||
f.comment {|x| x.association(:comment)}
|
||||
f.user {|x| x.association(:user)}
|
||||
f.score 1
|
||||
end
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
Factory.define(:unapproval) do |f|
|
||||
f.post {|x| x.association(:post)}
|
||||
f.reason "xxx"
|
||||
end
|
||||
@@ -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
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user