Skip to content

Commit

Permalink
Adds three basic content-type dl tests (#4005)
Browse files Browse the repository at this point in the history
  • Loading branch information
HazelGrant authored Dec 11, 2024
1 parent 641a738 commit 53a11c6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/dashboard/test/fixtures/files/download/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
one: 'two'
1 change: 1 addition & 0 deletions apps/dashboard/test/fixtures/files/download/test_text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
26 changes: 25 additions & 1 deletion apps/dashboard/test/integration/files_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,31 @@ def upload_and_test(filename, content_type: 'text/plain')
end
end

def download_and_test(filename, content_type)
Dir.mktmpdir do |tmpdir|
src_file = "test/fixtures/files/download/#{filename}"
dest_file = "#{tmpdir}/#{filename}"

put_file("#{files_path}/#{dest_file}", src_file)

get files_path(filepath: dest_file, download: true)

assert_equal response.headers["Content-Type"], content_type
end
end

test "can download file as text/plain" do
download_and_test("test_text.txt", "text/plain")
end

test "can download file as image/png" do
download_and_test("osc-logo.png", "image/png")
end

test "can download file as application/x-yaml" do
download_and_test("test.yml", "application/x-yaml")
end

test "can upload file with non-ASCII characters" do
upload_and_test("funny_characters.sh")
end
Expand All @@ -54,5 +79,4 @@ def upload_and_test(filename, content_type: 'text/plain')
test "can upload file binary files as text/plain as application/octet-stream" do
upload_and_test("hello-world-c", content_type: 'application/octet-stream')
end

end

0 comments on commit 53a11c6

Please sign in to comment.