artists: fix ban/unban actions.

Fix the ban! and unban! methods to:

* Lock the artist while it is being banned or unbanned.
* Perform the edits as a mass update, so that the posts are updated in parallel.
* Edit the artist as the banner rather than as the current user.
* Soft delete the banned_artist implication when an artist is unbanned instead of hard deleting it.
* Ignore the banned_artist implication if it's deleted.
This commit is contained in:
evazion
2022-11-20 18:33:15 -06:00
parent 01c6d11253
commit 4fd028a5ce
5 changed files with 32 additions and 29 deletions

View File

@@ -132,12 +132,12 @@ class ArtistsControllerTest < ActionDispatch::IntegrationTest
context "unban action" do
should "unban an artist" do
as(@admin) { @artist.ban!(banner: @admin) }
@artist.ban!(@admin)
put_auth unban_artist_path(@artist.id), @admin
assert_redirected_to(@artist)
assert_equal(false, @artist.reload.is_banned?)
assert_equal(false, TagImplication.exists?(antecedent_name: @artist.name, consequent_name: "banned_artist"))
assert_equal(true, TagImplication.deleted.exists?(antecedent_name: @artist.name, consequent_name: "banned_artist"))
end
end