Remove super voters.

This commit is contained in:
evazion
2020-02-23 17:46:13 -06:00
parent 1591df0351
commit ce11485fe0
17 changed files with 18 additions and 267 deletions

View File

@@ -1,4 +0,0 @@
FactoryBot.define do
factory(:super_voter) do
end
end

View File

@@ -36,7 +36,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
context "show action" do
setup do
# flesh out profile to get more test coverage of user presenter.
@user = create(:banned_user, can_approve_posts: true, is_super_voter: true, created_at: 2.weeks.ago)
@user = create(:banned_user, can_approve_posts: true, created_at: 2.weeks.ago)
as_user do
create(:saved_search, user: @user)
create(:post, uploader: @user, tag_string: "fav:#{@user.name}")

View File

@@ -2,10 +2,6 @@ require 'test_helper'
class DanbooruMaintenanceTest < ActiveSupport::TestCase
context "daily maintenance" do
setup do
@admin = create(:admin_user) # for SuperVoter.init!
end
should "work" do
assert_nothing_raised { DanbooruMaintenance.daily }
end

View File

@@ -1765,12 +1765,9 @@ class PostTest < ActiveSupport::TestCase
@user1 = FactoryBot.create(:user, enable_private_favorites: true)
@gold1 = FactoryBot.create(:gold_user)
@supervoter1 = FactoryBot.create(:user, is_super_voter: true)
@child.add_favorite!(@user1)
@child.add_favorite!(@gold1)
@child.add_favorite!(@supervoter1)
@parent.add_favorite!(@supervoter1)
@child.give_favorites_to_parent
@child.reload
@@ -1789,7 +1786,6 @@ class PostTest < ActiveSupport::TestCase
should "create a vote for each user who can vote" do
assert(@parent.votes.where(user: @gold1).exists?)
assert(@parent.votes.where(user: @supervoter1).exists?)
assert_equal(4, @parent.score)
end
end
@@ -2534,24 +2530,6 @@ class PostTest < ActiveSupport::TestCase
end
context "Voting:" do
context "with a super voter" do
setup do
@user = FactoryBot.create(:user)
FactoryBot.create(:super_voter, user: @user)
@post = FactoryBot.create(:post)
end
should "account for magnitude" do
CurrentUser.scoped(@user, "127.0.0.1") do
assert_nothing_raised {@post.vote!("up")}
assert_raises(PostVote::Error) {@post.vote!("up")}
@post.reload
assert_equal(1, PostVote.count)
assert_equal(SuperVoter::MAGNITUDE, @post.score)
end
end
end
should "not allow members to vote" do
@user = FactoryBot.create(:user)
@post = FactoryBot.create(:post)

View File

@@ -4,7 +4,6 @@ class PostVoteTest < ActiveSupport::TestCase
def setup
super
@supervoter = FactoryBot.create(:user, is_super_voter: true)
@user = FactoryBot.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
@@ -23,11 +22,6 @@ class PostVoteTest < ActiveSupport::TestCase
assert_equal(-1, vote.score)
end
should "interpret up as +3 score for a supervoter" do
vote = PostVote.create(:user_id => @supervoter.id, :post_id => @post.id, :vote => "up")
assert_equal(3, vote.score)
end
should "not accept any other scores" do
vote = PostVote.create(:post_id => @post.id, :vote => "xxx")
assert(vote.errors.any?)
@@ -48,13 +42,5 @@ class PostVoteTest < ActiveSupport::TestCase
assert_equal(0, @post.score)
assert_equal(0, @post.up_score)
end
should "upvote by 3 points if the voter is a supervoter" do
@post.votes.create(user: @supervoter, vote: "up")
@post.reload
assert_equal(3, @post.score)
assert_equal(3, @post.up_score)
end
end
end

View File

@@ -1,42 +0,0 @@
require 'test_helper'
class SuperVoterTest < ActiveSupport::TestCase
def setup
super
@user = FactoryBot.create(:user)
end
context "#init" do
setup do
@admin = FactoryBot.create(:admin_user)
@user_mock = mock("user")
@user_mock.expects(:user_id).twice.returns(@user.id)
@admin_mock = mock("admin")
@admin_mock.expects(:user_id).twice.returns(@admin.id)
PostVoteSimilarity.any_instance.stubs(:calculate_positive).returns([@admin_mock, @user_mock])
end
should "create super voter objects" do
assert_difference("SuperVoter.count", 2) do
SuperVoter.init!
end
end
end
context "creation" do
should "update the is_super_voter field on the user object" do
FactoryBot.create(:super_voter, user: @user)
@user.reload
assert_equal(true, @user.is_super_voter?)
end
end
context "destruction" do
should "update the is_super_voter field on the user object" do
voter = FactoryBot.create(:super_voter, user: @user)
voter.destroy
@user.reload
assert_equal(false, @user.is_super_voter?)
end
end
end