handle the case where a file is uploaded that doesn't match whatever was preprocessed
This commit is contained in:
@@ -35,7 +35,7 @@ class UploadsControllerTest < ActionDispatch::IntegrationTest
|
||||
context "preprocess action" do
|
||||
should "prefer the file over the source when preprocessing" do
|
||||
file = Rack::Test::UploadedFile.new("#{Rails.root}/test/files/test.jpg", "image/jpeg")
|
||||
post_auth preprocess_uploads_path, @user, params: {:url => "http://www.google.com/intl/en_ALL/images/logo.gif", :file => file}
|
||||
post_auth preprocess_uploads_path, @user, params: {:url => "https://raikou1.donmai.us/d3/4e/d34e4cf0a437a5d65f8e82b7bcd02606.jpg", :file => file}
|
||||
assert_response :success
|
||||
Delayed::Worker.new.work_off
|
||||
assert_equal("ecef68c44edb8a0d6a3070b5f8e8ee76", Upload.last.md5)
|
||||
@@ -51,10 +51,21 @@ class UploadsControllerTest < ActionDispatch::IntegrationTest
|
||||
context "with a url" do
|
||||
should "preprocess" do
|
||||
assert_difference(-> { Upload.count }) do
|
||||
get_auth new_upload_path, @user, params: {:url => "http://www.google.com/intl/en_ALL/images/logo.gif"}
|
||||
get_auth new_upload_path, @user, params: {:url => "https://raikou1.donmai.us/d3/4e/d34e4cf0a437a5d65f8e82b7bcd02606.jpg"}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
should "prefer the file" do
|
||||
get_auth new_upload_path, @user, params: {url: "https://raikou1.donmai.us/d3/4e/d34e4cf0a437a5d65f8e82b7bcd02606.jpg"}
|
||||
Delayed::Worker.new.work_off
|
||||
file = Rack::Test::UploadedFile.new("#{Rails.root}/test/files/test.jpg", "image/jpeg")
|
||||
assert_difference(-> { Post.count }) do
|
||||
post_auth uploads_path, @user, params: {upload: {file: file, tag_string: "aaa", rating: "q", source: "https://raikou1.donmai.us/d3/4e/d34e4cf0a437a5d65f8e82b7bcd02606.jpg"}}
|
||||
end
|
||||
post = Post.last
|
||||
assert_equal("ecef68c44edb8a0d6a3070b5f8e8ee76", post.md5)
|
||||
end
|
||||
end
|
||||
|
||||
context "for a twitter post" do
|
||||
|
||||
Reference in New Issue
Block a user