From d19abd7ddb962fadd568229e542f91c97a2c7a94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 17 Jan 2020 19:57:53 +0100 Subject: [PATCH] Fix uploading images through CKEditor's upload tab The bug was introduced when we upgraded the ckeditor gem in commit f240e007. --- app/assets/javascripts/ckeditor/config.js | 1 + spec/features/ckeditor_spec.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/app/assets/javascripts/ckeditor/config.js b/app/assets/javascripts/ckeditor/config.js index 78be62b99..422182e05 100644 --- a/app/assets/javascripts/ckeditor/config.js +++ b/app/assets/javascripts/ckeditor/config.js @@ -15,6 +15,7 @@ CKEDITOR.editorConfig = function( config ) config.filebrowserImageBrowseUrl = "/ckeditor/pictures"; config.filebrowserImageUploadUrl = "/ckeditor/pictures"; config.filebrowserUploadUrl = "/ckeditor/attachment_files"; + config.filebrowserUploadMethod = "form"; config.allowedContent = true; config.format_tags = "p;h2;h3"; diff --git a/spec/features/ckeditor_spec.rb b/spec/features/ckeditor_spec.rb index ac29091dd..8a8b9d9f2 100644 --- a/spec/features/ckeditor_spec.rb +++ b/spec/features/ckeditor_spec.rb @@ -14,4 +14,20 @@ describe "CKEditor" do expect(page).to have_css ".translatable-fields[data-locale='en'] .cke_wysiwyg_frame" end + + scenario "uploading an image through the upload tab", :js do + login_as(create(:administrator).user) + + visit new_admin_site_customization_page_path + find(".cke_button__image").click + click_link "Upload" + + within_frame(1) do + attach_file "Send it to the Server", Rails.root.join("spec/fixtures/files/clippy.jpg") + end + + click_link "Send it to the Server" + + expect(page).to have_css "img[src$='clippy.jpg']" + end end