Fix #4359: Allow builders to move small (artist) tags manually.

Allow builders to approve artist alias BURs. The BUR must contain only
artist aliases or mass updates and each artist must have less than 100
posts.
This commit is contained in:
evazion
2020-05-11 00:20:21 -05:00
parent e3187e0bd0
commit d136a12a65
5 changed files with 60 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ class BulkUpdateRequestsControllerTest < ActionDispatch::IntegrationTest
context "BulkUpdateRequestsController" do
setup do
@user = create(:user)
@builder = create(:builder_user)
@admin = create(:admin_user)
@bulk_update_request = create(:bulk_update_request, user: @user)
end
@@ -121,6 +122,33 @@ class BulkUpdateRequestsControllerTest < ActionDispatch::IntegrationTest
end
end
context "for a builder" do
should "fail for a large artist move" do
create(:tag, name: "artist1", category: Tag.categories.artist, post_count: 1000)
@bulk_update_request = create(:bulk_update_request, script: "create alias artist1 -> artist2")
post_auth approve_bulk_update_request_path(@bulk_update_request), @builder
assert_response 403
assert_equal("pending", @bulk_update_request.reload.status)
assert_equal(false, TagAlias.where(antecedent_name: "artist1", consequent_name: "artist2").exists?)
end
should "succeed for a small artist move" do
create(:tag, name: "artist1a", category: Tag.categories.artist, post_count: 10)
create(:tag, name: "artist1b", category: Tag.categories.general, post_count: 0)
create(:tag, name: "artist2a", category: Tag.categories.artist, post_count: 20)
@bulk_update_request = create(:bulk_update_request, script: "mass update artist1a -> artist1b\ncreate alias artist2a -> artist2b")
post_auth approve_bulk_update_request_path(@bulk_update_request), @builder
assert_redirected_to(bulk_update_requests_path)
assert_equal("approved", @bulk_update_request.reload.status)
assert_equal(@builder, @bulk_update_request.approver)
assert_equal(true, TagAlias.where(antecedent_name: "artist2a", consequent_name: "artist2b").exists?)
end
end
context "for an admin" do
should "succeed" do
post_auth approve_bulk_update_request_path(@bulk_update_request), @admin