Skip to content

Commit

Permalink
tests: fix upload controller tests.
Browse files Browse the repository at this point in the history
We can't use the name `test_file_upload` because then the helper method
gets treated like it's a test case.
  • Loading branch information
evazion committed Jun 2, 2020
1 parent 276f23b commit 18ce552
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/functional/uploads_controller_test.rb
@@ -1,7 +1,7 @@
require 'test_helper'

class UploadsControllerTest < ActionDispatch::IntegrationTest
def test_file_upload(file_path, user, **upload_params)
def assert_uploaded(file_path, user, **upload_params)
file = Rack::Test::UploadedFile.new("#{Rails.root}/#{file_path}")

assert_difference(["Upload.count", "Post.count"]) do
Expand Down Expand Up @@ -252,7 +252,7 @@ def test_file_upload(file_path, user, **upload_params)

context "uploading a file from your computer" do
should "work for a jpeg file" do
upload = test_file_upload("test/files/test.jpg", @user, tag_string: "aaa", rating: "e", source: "aaa")
upload = assert_uploaded("test/files/test.jpg", @user, tag_string: "aaa", rating: "e", source: "aaa")

assert_equal("jpg", upload.post.file_ext)
assert_equal("aaa", upload.post.source)
Expand All @@ -261,7 +261,7 @@ def test_file_upload(file_path, user, **upload_params)
end

should "work for a webm file" do
upload = test_file_upload("test/files/test-512x512.webm", @user, tag_string: "aaa", rating: "e", source: "aaa")
upload = assert_uploaded("test/files/test-512x512.webm", @user, tag_string: "aaa", rating: "e", source: "aaa")

assert_equal("webm", upload.post.file_ext)
assert_equal("aaa", upload.post.source)
Expand All @@ -270,7 +270,7 @@ def test_file_upload(file_path, user, **upload_params)
end

should "work for a flash file" do
upload = test_file_upload("test/files/compressed.swf", @user, tag_string: "aaa", rating: "e", source: "aaa")
upload = assert_uploaded("test/files/compressed.swf", @user, tag_string: "aaa", rating: "e", source: "aaa")

assert_equal("swf", upload.post.file_ext)
assert_equal("aaa", upload.post.source)
Expand Down

0 comments on commit 18ce552

Please sign in to comment.