tests: fix various broken tests.

This commit is contained in:
evazion
2020-01-18 19:04:58 -06:00
parent cbbeac00df
commit 79015b4341
4 changed files with 24 additions and 24 deletions

View File

@@ -16,7 +16,7 @@ class PostReplacementsControllerTest < ActionDispatch::IntegrationTest
format: :json,
post_id: @post.id,
post_replacement: {
replacement_url: "https://raikou1.donmai.us/d3/4e/d34e4cf0a437a5d65f8e82b7bcd02606.jpg"
replacement_url: "https://cdn.donmai.us/original/d3/4e/d34e4cf0a437a5d65f8e82b7bcd02606.jpg"
}
}
@@ -29,7 +29,7 @@ class PostReplacementsControllerTest < ActionDispatch::IntegrationTest
perform_enqueued_jobs
assert_response :success
assert_equal("https://raikou1.donmai.us/d3/4e/d34e4cf0a437a5d65f8e82b7bcd02606.jpg", @post.source)
assert_equal("https://cdn.donmai.us/original/d3/4e/d34e4cf0a437a5d65f8e82b7bcd02606.jpg", @post.source)
assert_equal("d34e4cf0a437a5d65f8e82b7bcd02606", @post.md5)
assert_equal("d34e4cf0a437a5d65f8e82b7bcd02606", Digest::MD5.file(@post.file(:original)).hexdigest)
end

View File

@@ -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: {:upload => {:source => "https://raikou1.donmai.us/d3/4e/d34e4cf0a437a5d65f8e82b7bcd02606.jpg", :file => file}}
post_auth preprocess_uploads_path, @user, params: {:upload => {:source => "https://cdn.donmai.us/original/d3/4e/d34e4cf0a437a5d65f8e82b7bcd02606.jpg", :file => file}}
assert_response :success
perform_enqueued_jobs
assert_equal("ecef68c44edb8a0d6a3070b5f8e8ee76", Upload.last.md5)
@@ -51,18 +51,18 @@ 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 => "https://raikou1.donmai.us/d3/4e/d34e4cf0a437a5d65f8e82b7bcd02606.jpg"}
get_auth new_upload_path, @user, params: {:url => "https://cdn.donmai.us/original/d3/4e/d34e4cf0a437a5d65f8e82b7bcd02606.jpg"}
perform_enqueued_jobs
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"}
get_auth new_upload_path, @user, params: {url: "https://cdn.donmai.us/original/d3/4e/d34e4cf0a437a5d65f8e82b7bcd02606.jpg"}
perform_enqueued_jobs
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"}}
post_auth uploads_path, @user, params: {upload: {file: file, tag_string: "aaa", rating: "q", source: "https://cdn.donmai.us/original/d3/4e/d34e4cf0a437a5d65f8e82b7bcd02606.jpg"}}
end
post = Post.last
assert_equal("ecef68c44edb8a0d6a3070b5f8e8ee76", post.md5)

View File

@@ -92,7 +92,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
should "redirect anonymous users to the sign in page" do
get profile_path
assert_redirected_to new_session_path
assert_redirected_to login_path(url: "/profile")
end
should "return 404 for anonymous api calls" do
@@ -150,7 +150,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
should "redirect anonymous users to the sign in page" do
get settings_path
assert_redirected_to new_session_path
assert_redirected_to login_path(url: "/settings")
end
end