Skip to content

A platform for community discussion. Free, open, simple.

FIX: UppyUploader issues when authorized_extensions setting is blank but authorized_extensions_for_staff is not (#33423)

Juan David Martínez Cubillos8ffc9dcb706a
diff --git a/app/assets/javascripts/discourse/app/lib/uppy/uppy-upload.js b/app/assets/javascripts/discourse/app/lib/uppy/uppy-upload.js
index 32044f6da27..bbbad4dbac8 100644
--- a/app/assets/javascripts/discourse/app/lib/uppy/uppy-upload.js
+++ b/app/assets/javascripts/discourse/app/lib/uppy/uppy-upload.js
@@ -89,6 +89,7 @@ export default class UppyUpload {
@service siteSettings;
@service capabilities;
@service session;
+ @service currentUser;
@tracked uploading = false;
@tracked processing = false;
diff --git a/spec/system/edit_category_images_spec.rb b/spec/system/edit_category_images_spec.rb
new file mode 100644
index 00000000000..9309a90244e
--- /dev/null
+++ b/spec/system/edit_category_images_spec.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+describe "Edit Category Images", type: :system do
+ fab!(:admin)
+ fab!(:category)
+ let(:category_page) { PageObjects::Pages::Category.new }
+
+ context "when trying to upload an image" do
+ before { sign_in(admin) }
+
+ context "when authorized_extensions blank and authorized_extensions_for_staff have restrictions" do
+ before do
+ SiteSetting.authorized_extensions = ""
+ SiteSetting.authorized_extensions_for_staff = "jpg|jpeg|png"
+ SiteSetting.enable_s3_uploads = false
+ end
+
+ it "displays and updates new counter" do
+ category_page.visit_images(category)
+
+ find("#category-logo-uploader .image-upload-controls").click
+ attach_file(
+ "category-logo-uploader__input",
+ "#{Rails.root}/spec/fixtures/images/logo.png",
+ make_visible: true,
+ )
+
+ expect(page).to have_content("uploaded successfully").or have_css(
+ ".uploaded-image-preview.input-xxlarge",
+ )
+
+ upload = Upload.last
+ expect(upload.user_id).to eq(admin.id)
+ expect(upload.original_filename).to eq("logo.png")
+ end
+ end
+ end
+end
diff --git a/spec/system/page_objects/pages/category.rb b/spec/system/page_objects/pages/category.rb
index 0b79e8d996a..5b33da95e48 100644
--- a/spec/system/page_objects/pages/category.rb
+++ b/spec/system/page_objects/pages/category.rb
@@ -39,6 +39,11 @@ module PageObjects
self
end
+ def visit_images(category)
+ page.visit("/c/#{category.slug}/edit/images")
+ self
+ end
+
def back_to_category
find(".edit-category-title-bar span", text: "Back to category").click
self