add test case for handling uploads without extension

This commit is contained in:
Arpit Jalan 2016-12-20 00:09:04 +05:30
parent 4dcb29acbf
commit a2096a01fb
1 changed files with 11 additions and 1 deletions

View File

@ -170,7 +170,7 @@ describe UploadsController do
expect(response.response_code).to eq(404)
end
it "returns 404 when the upload doens't exist" do
it "returns 404 when the upload doesn't exist" do
Upload.stubs(:find_by).returns(nil)
get :show, site: site, sha: sha, extension: "pdf"
@ -187,6 +187,16 @@ describe UploadsController do
get :show, site: site, sha: sha, extension: "zip"
end
it "handles file without extension" do
SiteSetting.authorized_extensions = "*"
upload = Fabricate(:upload, original_filename: "image_file", sha1: sha)
controller.stubs(:render)
controller.expects(:send_file)
get :show, site: site, sha: sha
expect(response).to be_success
end
context "prevent anons from downloading files" do
before { SiteSetting.stubs(:prevent_anons_from_downloading_files).returns(true) }