Implement forum topic voting and tag change pruning (#3580)

This commit is contained in:
Albert Yi
2018-04-16 16:09:39 -07:00
parent 45fad069d7
commit f2b525a6d2
182 changed files with 558 additions and 554 deletions

View File

@@ -0,0 +1,36 @@
require 'test_helper'
class ForumPostVotesControllerTest < ActionDispatch::IntegrationTest
context "The forum post votes controller" do
setup do
@user = create(:user)
as_user do
@forum_topic = create(:forum_topic)
@forum_post = create(:forum_post, topic: @forum_topic)
end
end
should "allow voting" do
assert_difference("ForumPostVote.count") do
post_auth forum_post_votes_path(forum_post_id: @forum_post.id), @user, params: {forum_post_vote: {score: 1}, format: "js"}
end
assert_response :success
end
context "when deleting" do
setup do
as_user do
@forum_post_vote = @forum_post.votes.create(score: 1)
end
end
should "allow removal" do
assert_difference("ForumPostVote.count", -1) do
delete_auth forum_post_votes_path(forum_post_id: @forum_post.id), @user, params: {format: "js"}
end
assert_response :success
end
end
end
end