post regenerations: replace PostRegeneration model with mod actions.

* Remove the PostRegeneration model. Instead just use a mod action
  to log when a post is regenerated.

* Change it so that IQDB is also updated when the image samples are
  regenerated. This is necessary because when the images samples are
  regenerated, the thumbnail may change, which means IQDB needs to be
  updated too. This can happen when regenerating old images with
  transparent backgrounds where the transparency was flattened to black
  instead of white in the thumbnail.

* Only display one "Regenerate image" option in the post sidebar, to
  regenerate both the images and IQDB. Regenerating IQDB only can be
  done through the API. Having two options in the sidebar is too much
  clutter, and it's too confusing for Mods who don't know the difference
  between an IQDB-only regeneration and a full image regeneration.

* Add a confirm prompt to the "Regenerate image" link.
This commit is contained in:
evazion
2021-01-04 15:59:36 -06:00
parent 913ce88024
commit df44937c57
15 changed files with 34 additions and 189 deletions

View File

@@ -6,43 +6,18 @@ class PostRegenerationsControllerTest < ActionDispatch::IntegrationTest
@mod = create(:moderator_user, name: "yukari", created_at: 1.month.ago)
as(@mod) do
@post = create(:post, source: "https://google.com", tag_string: "touhou")
@post_regeneration = create(:post_regeneration, creator: @mod, category: "iqdb")
end
end
context "create action" do
should "render" do
assert_difference("PostRegeneration.count") do
post_auth post_regenerations_path, @mod, params: {format: :json, post_regeneration: {post_id: @post.id, category: "iqdb"}}
assert_response :success
end
end
should "not allow non-mods to regenerate posts" do
assert_difference("PostRegeneration.count", 0) do
post_auth post_regenerations_path, create(:user), params: {format: :json, post_regeneration: {post_id: @post.id, category: "iqdb"}}
assert_response 403
end
end
end
context "index action" do
setup do
@admin = create(:admin_user)
as(@admin) { @admin_regeneration = create(:post_regeneration, post: @post, creator: @admin, category: "resizes") }
end
should "render" do
get post_regenerations_path
post_auth post_regenerations_path, @mod, params: { post_id: @post.id, category: "iqdb" }
assert_response :success
end
should respond_to_search({}).with { [@admin_regeneration, @post_regeneration] }
should respond_to_search(category: "iqdb").with { @post_regeneration }
context "using includes" do
should respond_to_search(post_tags_match: "touhou").with { @admin_regeneration }
should respond_to_search(creator: {level: User::Levels::ADMIN}).with { @admin_regeneration }
should "not allow non-mods to regenerate posts" do
post_auth post_regenerations_path, create(:user), params: { post_id: @post.id, category: "iqdb" }
assert_response 403
end
end
end