Fix #3534: Remove Janitor Trials.

This commit is contained in:
evazion
2019-11-17 02:05:01 -06:00
parent 1ae971269c
commit 72f17fd1de
19 changed files with 11 additions and 436 deletions

View File

@@ -1,5 +0,0 @@
FactoryBot.define do
factory(:janitor_trial) do
user
end
end

View File

@@ -1,77 +0,0 @@
require 'test_helper'
class JanitorTrialsControllerTest < ActionDispatch::IntegrationTest
context "The janitor trials controller" do
setup do
@admin = create(:admin_user)
@user = create(:user)
end
context "new action" do
should "render" do
get_auth new_janitor_trial_path, @admin
assert_response :success
end
end
context "create action" do
should "create a new janitor trial" do
assert_difference("JanitorTrial.count", 1) do
post_auth janitor_trials_path, @admin, params: {:janitor_trial => {:user_id => @user.id}}
end
end
end
context "promote action" do
setup do
as(@admin) do
@janitor_trial = create(:janitor_trial, :user_id => @user.id)
end
end
should "promote the janitor trial" do
put_auth promote_janitor_trial_path(@janitor_trial), @admin
@user.reload
assert(@user.can_approve_posts?)
@janitor_trial.reload
assert_equal(false, @janitor_trial.active?)
end
end
context "demote action" do
setup do
as(@admin) do
@janitor_trial = create(:janitor_trial, :user_id => @user.id)
end
end
should "demote the janitor trial" do
put_auth demote_janitor_trial_path(@janitor_trial), @admin
@user.reload
assert(!@user.can_approve_posts?)
@janitor_trial.reload
assert_equal(false, @janitor_trial.active?)
end
end
context "index action" do
setup do
as(@admin) do
create(:janitor_trial)
end
end
should "render" do
get_auth janitor_trials_path, @admin
assert_response :success
end
context "with search parameters" do
should "render" do
get_auth janitor_trials_path, @admin, params: {:search => {:user_name => @user.name}}
assert_response :success
end
end
end
end
end

View File

@@ -1,60 +0,0 @@
require 'test_helper'
class JanitorTrialTest < ActiveSupport::TestCase
context "A janitor trial" do
setup do
@admin = FactoryBot.create(:admin_user)
@user = FactoryBot.create(:user)
CurrentUser.user = @admin
CurrentUser.ip_addr = "127.0.0.1"
end
teardown do
CurrentUser.user = nil
CurrentUser.ip_addr = nil
end
context "upon creation" do
should "create a dmail when testing a new janitor" do
assert_difference("Dmail.count", 2) do
JanitorTrial.create(:user_id => @user.id)
end
end
should "toggle the can_approve_posts flag on the user" do
janitor_trial = JanitorTrial.create(:user_id => @user.id)
@user.reload
assert(@user.can_approve_posts?)
end
end
context "upon demotion" do
setup do
@janitor_trial = FactoryBot.create(:janitor_trial, :user_id => @user.id)
end
should "create a negative feedback record" do
assert_difference("UserFeedback.count", 1) do
@janitor_trial.demote!
end
end
should "revoke approval privileges" do
@janitor_trial.demote!
@user.reload
assert_equal(false, @user.can_approve_posts?)
end
end
context "upon promotion" do
setup do
@janitor_trial = FactoryBot.create(:janitor_trial, :user_id => @user.id)
end
should "destroy the trial object" do
@janitor_trial.promote!
assert_equal(false, @janitor_trial.active?)
end
end
end
end