diff --git a/apps/dashboard/test/fixtures/files/download/osc-logo.png b/apps/dashboard/test/fixtures/files/download/osc-logo.png new file mode 100644 index 0000000000..13ff88b0dd Binary files /dev/null and b/apps/dashboard/test/fixtures/files/download/osc-logo.png differ diff --git a/apps/dashboard/test/fixtures/files/download/test.yml b/apps/dashboard/test/fixtures/files/download/test.yml new file mode 100644 index 0000000000..ec8db38f02 --- /dev/null +++ b/apps/dashboard/test/fixtures/files/download/test.yml @@ -0,0 +1 @@ +one: 'two' \ No newline at end of file diff --git a/apps/dashboard/test/fixtures/files/download/test_text.txt b/apps/dashboard/test/fixtures/files/download/test_text.txt new file mode 100644 index 0000000000..30d74d2584 --- /dev/null +++ b/apps/dashboard/test/fixtures/files/download/test_text.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/apps/dashboard/test/integration/files_test.rb b/apps/dashboard/test/integration/files_test.rb index 47e223c920..1a616869d0 100644 --- a/apps/dashboard/test/integration/files_test.rb +++ b/apps/dashboard/test/integration/files_test.rb @@ -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 @@ -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 \ No newline at end of file