+ <%= f.text_area :description,
maxlength: Legislation::Proposal.description_max_length,
- ckeditor: { language: I18n.locale } %>
+ class: "html-area" %>
diff --git a/app/views/proposals/_form.html.erb b/app/views/proposals/_form.html.erb
index 6f2a34e82..eba35f60d 100644
--- a/app/views/proposals/_form.html.erb
+++ b/app/views/proposals/_form.html.erb
@@ -21,10 +21,10 @@
hint: t("proposals.form.proposal_summary_note") %>
- <%= translations_form.cktext_area :description,
- maxlength: Proposal.description_max_length,
- ckeditor: { language: I18n.locale } %>
+
+ <%= translations_form.text_area :description,
+ maxlength: Proposal.description_max_length,
+ class: "html-area" %>
<% end %>
diff --git a/lib/consul_form_builder.rb b/lib/consul_form_builder.rb
index 86c84589f..33b0fc1af 100644
--- a/lib/consul_form_builder.rb
+++ b/lib/consul_form_builder.rb
@@ -9,7 +9,7 @@ class ConsulFormBuilder < FoundationRailsHelper::FormBuilder
select attribute, choices, options, html_options
end
- %i[text_field text_area cktext_area number_field password_field email_field].each do |field|
+ %i[text_field text_area number_field password_field email_field].each do |field|
define_method field do |attribute, options = {}|
label_with_hint(attribute, options.merge(label_options: label_options_for(options))) +
super(attribute, options.merge(
diff --git a/spec/features/admin/site_customization/pages_spec.rb b/spec/features/admin/site_customization/pages_spec.rb
index 42042f028..3671ba64a 100644
--- a/spec/features/admin/site_customization/pages_spec.rb
+++ b/spec/features/admin/site_customization/pages_spec.rb
@@ -86,10 +86,9 @@ describe "Admin custom pages" do
scenario "Allows images in CKEditor", :js do
visit edit_admin_site_customization_page_path(custom_page)
+ fill_in_ckeditor "Content", with: "Will add an image"
- within(".ckeditor") do
- expect(page).to have_css(".cke_toolbar .cke_button__image_icon")
- end
+ expect(page).to have_css(".cke_toolbar .cke_button__image_icon")
end
end
diff --git a/spec/features/admin/translatable_spec.rb b/spec/features/admin/translatable_spec.rb
index 9a9b76d98..c40919d81 100644
--- a/spec/features/admin/translatable_spec.rb
+++ b/spec/features/admin/translatable_spec.rb
@@ -55,15 +55,15 @@ describe "Admin edit translatable records" do
visit path
- within_frame(0) { expect(page).to have_content "Content in English" }
+ expect(page).to have_ckeditor "Content", with: "Content in English"
select "Español", from: :select_language
- within_frame(0) { expect(page).to have_content "Contenido en español" }
+ expect(page).to have_ckeditor "Content", with: "Contenido en español"
select "Français", from: :select_language
- within_frame(0) { expect(page).to have_content "Contenu en Français" }
+ expect(page).to have_ckeditor "Content", with: "Contenu en Français"
end
end
@@ -155,7 +155,7 @@ describe "Admin edit translatable records" do
select "Français", from: :select_language
- within_frame(0) { expect(page.text).to be_empty }
+ expect(page). to have_ckeditor "Description", with: ""
end
end
@@ -237,7 +237,7 @@ describe "Admin edit translatable records" do
select("Español", from: "locale-switcher")
expect(page).to have_field "Respuesta", with: "Respuesta corregida"
- within_frame(0) { expect(page).to have_content "Descripción corregida" }
+ expect(page).to have_ckeditor "Descripción", with: "Descripción corregida"
end
end
diff --git a/spec/features/translatable_spec.rb b/spec/features/translatable_spec.rb
index a750947fa..d075f1487 100644
--- a/spec/features/translatable_spec.rb
+++ b/spec/features/translatable_spec.rb
@@ -212,7 +212,7 @@ describe "Public area translatable records" do
select "Español", from: "locale-switcher"
expect(page).to have_field "Título del debate", with: "Título corregido"
- within_frame(0) { expect(page).to have_content "Texto corregido" }
+ expect(page).to have_ckeditor "Texto inicial del debate", with: "Texto corregido"
end
end
diff --git a/spec/support/matchers/have_ckeditor.rb b/spec/support/matchers/have_ckeditor.rb
new file mode 100644
index 000000000..8072ad511
--- /dev/null
+++ b/spec/support/matchers/have_ckeditor.rb
@@ -0,0 +1,31 @@
+RSpec::Matchers.define :have_ckeditor do |label, with:|
+ define_method :textarea_id do
+ find("label", text: label)[:for]
+ end
+
+ define_method :ckeditor_id do
+ "#cke_#{textarea_id}"
+ end
+
+ define_method :has_ckeditor? do
+ has_css?("label", text: label) && has_css?(ckeditor_id)
+ end
+
+ match do
+ return false unless has_ckeditor?
+
+ page.within(ckeditor_id) do
+ within_frame(0) { has_content?(with) }
+ end
+ end
+
+ failure_message do
+ if has_ckeditor?
+ text = page.within(ckeditor_id) { within_frame(0) { page.text } }
+
+ "expected to find visible CKEditor '#{label}' with '#{with}', but had '#{text}'"
+ else
+ "expected to find visible CKEditor '#{label}' but there were no matches."
+ end
+ end
+end