post replacements: refactor and fix tests.

* Move replacement tests from test/unit/upload_service_test.rb to
  test/functional/post_replacement_controller_test.rb
* Move UploadService::Replacer to PostReplacementProcessor.
* Fix a minor bug where if you used the API to replace a post with a file,
  the replacement would fail unless you passed an empty string for the
  replacement_url.
This commit is contained in:
evazion
2022-01-31 12:14:06 -06:00
parent 61c043c6b1
commit 65b7c08e33
9 changed files with 239 additions and 432 deletions

View File

@@ -1694,18 +1694,4 @@ class PostTest < ActiveSupport::TestCase
assert_equal("https://www.example.com/data/original/77/d8/77d89bda37ea3af09158ed3282f8334f.gif", @post.file_url)
end
end
context "#replace!" do
subject { @post.replace!(tags: "something", replacement_url: "https://danbooru.donmai.us/images/download-preview.png") }
setup do
@post = FactoryBot.create(:post)
end
should "update the post" do
assert_changes(-> { @post.md5 }) do
subject
end
end
end
end