From 6f96265a0befddb0d128877f9992403c8805aeee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 17 Oct 2018 19:24:55 +0200 Subject: [PATCH] Bring back CKEditor images button It was accidentally deleted in commit 914bfa6. Note the following spec passes on my machine if we add a `sleep 0.1` call in the `:wait_readable` part of ruby's `Net::Protocol#rbuf_fill`. Otherwise, it hangs forever after clicking the `.fileupload-file` div, which closes its window. It might be solved when upgrading rails, capybara, selenium or chromedriver. scenario "Allows images in CKEditor", :js do visit edit_admin_site_customization_page_path(custom_page) within(".ckeditor") do within_frame(0) { expect(page).not_to have_css("img") } expect(page).to have_css(".cke_toolbar .cke_button__image_icon") find(".cke_toolbar .cke_button__image_icon").click end within_window(window_opened_by { click_link "Browse Server" }) do attach_file :file, Rails.root.join('spec/fixtures/files/clippy.jpg'), visible: false find(".fileupload-file").click end click_link "OK" within(".ckeditor") do within_frame(0) { expect(page).to have_css("img") } end end --- .../admin/site_customization/pages/_form.html.erb | 3 ++- .../features/admin/site_customization/pages_spec.rb | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/views/admin/site_customization/pages/_form.html.erb b/app/views/admin/site_customization/pages/_form.html.erb index c62a7142b..fa8fa81f9 100644 --- a/app/views/admin/site_customization/pages/_form.html.erb +++ b/app/views/admin/site_customization/pages/_form.html.erb @@ -41,7 +41,8 @@ <%= f.translatable_text_field :title %> <%= f.translatable_text_field :subtitle %>
- <%= f.translatable_cktext_area :content %> + <%= f.translatable_cktext_area :content, + ckeditor: { language: I18n.locale, toolbar: "admin" } %>
<%= f.submit class: "button success expanded" %> diff --git a/spec/features/admin/site_customization/pages_spec.rb b/spec/features/admin/site_customization/pages_spec.rb index b0f4a40e5..4270df93d 100644 --- a/spec/features/admin/site_customization/pages_spec.rb +++ b/spec/features/admin/site_customization/pages_spec.rb @@ -41,8 +41,11 @@ feature "Admin custom pages" do end context "Update" do - scenario "Valid custom page" do + let!(:custom_page) do create(:site_customization_page, title: "An example custom page", slug: "custom-example-page") + end + + scenario "Valid custom page" do visit admin_root_path within("#side_menu") do @@ -62,6 +65,14 @@ feature "Admin custom pages" do expect(page).to have_content "Another example custom page" expect(page).to have_content "another-custom-example-page" end + + scenario "Allows images in CKEditor", :js do + visit edit_admin_site_customization_page_path(custom_page) + + within(".ckeditor") do + expect(page).to have_css(".cke_toolbar .cke_button__image_icon") + end + end end scenario "Delete" do