A platform for community discussion. Free, open, simple.
correct specs
Samd7b1919ead2b
diff --git a/lib/upload_creator.rb b/lib/upload_creator.rbindex 3bb50448382..5dd94de3a49 100644--- a/lib/upload_creator.rb+++ b/lib/upload_creator.rb@@ -82,7 +82,7 @@ class UploadCreator# otherwise validation will fail and we can not save# TODO decide if we only run the validation on the extensionif File.extname(@filename) != ".#{image_type}"- fixed_original_filename = "#{@filename}.fixed.#{image_type}"+ fixed_original_filename = "#{@filename}_fixed.#{image_type}"endenddiff --git a/spec/fixtures/images/not_an_image b/spec/fixtures/images/not_an_imagenew file mode 100644index 00000000000..acbe86c7c89--- /dev/null+++ b/spec/fixtures/images/not_an_image@@ -0,0 +1 @@+abcddiff --git a/spec/lib/upload_creator_spec.rb b/spec/lib/upload_creator_spec.rbindex 9c23672eeea..7a85c0ffb5b 100644--- a/spec/lib/upload_creator_spec.rb+++ b/spec/lib/upload_creator_spec.rb@@ -41,7 +41,7 @@ RSpec.describe UploadCreator doexpect(upload.extension).to eq('png')expect(File.extname(upload.url)).to eq('.png')- expect(upload.original_filename).to eq('png_as.bin.fixed.png')+ expect(upload.original_filename).to eq('png_as.bin_fixed.png')endend@@ -65,7 +65,7 @@ RSpec.describe UploadCreator doexpect(upload.extension).to eq('jpeg')expect(File.extname(upload.url)).to eq('.jpeg')- expect(upload.original_filename).to eq('logo.png.fixed.jpeg')+ expect(upload.original_filename).to eq('logo.png_fixed.jpeg')endendenddiff --git a/spec/models/upload_spec.rb b/spec/models/upload_spec.rbindex 5145c7ae70b..1ee24f9b953 100644--- a/spec/models/upload_spec.rb+++ b/spec/models/upload_spec.rb@@ -53,8 +53,7 @@ describe Upload doit "should create an invalid upload when the filename is blank" doSiteSetting.authorized_extensions = "*"-- created_upload = UploadCreator.new(image, nil).create_for(user_id)+ created_upload = UploadCreator.new(attachment, nil).create_for(user_id)expect(created_upload.valid?).to eq(false)enddiff --git a/spec/requests/uploads_controller_spec.rb b/spec/requests/uploads_controller_spec.rbindex fac1a98d8d2..7ac95c9bbc4 100644--- a/spec/requests/uploads_controller_spec.rb+++ b/spec/requests/uploads_controller_spec.rb@@ -206,13 +206,22 @@ describe UploadsController doexpect(response.headers["Content-Disposition"]).to eq("attachment; filename=\"logo.png\"")end- it "handles file without extension" do+ it "handles image without extension" doSiteSetting.authorized_extensions = "*"upload = upload_file("image_no_extension")get "/uploads/#{site}/#{upload.sha1}.json"expect(response.status).to eq(200)- expect(response.headers["Content-Disposition"]).to eq("attachment; filename=\"image_no_extension\"")+ expect(response.headers["Content-Disposition"]).to eq("attachment; filename=\"image_no_extension_fixed.png\"")+ end++ it "handles file without extension" do+ SiteSetting.authorized_extensions = "*"+ upload = upload_file("not_an_image")++ get "/uploads/#{site}/#{upload.sha1}.json"+ expect(response.status).to eq(200)+ expect(response.headers["Content-Disposition"]).to eq("attachment; filename=\"not_an_image\"")endcontext "prevent anons from downloading files" do