From de35d3986301f6df620b3ca25541ad765b682820 Mon Sep 17 00:00:00 2001 From: Antti Hukkanen Date: Mon, 8 May 2023 13:05:42 +0300 Subject: [PATCH] Change the participant initiatives editor toolbars type * Change the participant initiatives editor toolbars type * Fix the expectation in the initiative editor spec * Add specs to ensure correct editor in complete and edit views --- .../create_initiative/fill_data.html.erb | 2 +- .../create_initiative/previous_form.html.erb | 2 +- .../initiatives/initiatives/_form.html.erb | 2 +- .../spec/system/create_initiative_spec.rb | 13 ++++++++++++- .../spec/system/edit_initiative_spec.rb | 15 +++++++++++++++ 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/decidim-initiatives/app/views/decidim/initiatives/create_initiative/fill_data.html.erb b/decidim-initiatives/app/views/decidim/initiatives/create_initiative/fill_data.html.erb index fe6edc9a2121f..3438a95c3d9ed 100644 --- a/decidim-initiatives/app/views/decidim/initiatives/create_initiative/fill_data.html.erb +++ b/decidim-initiatives/app/views/decidim/initiatives/create_initiative/fill_data.html.erb @@ -45,7 +45,7 @@
- <%= text_editor_for(f, :description, lines: 8, toolbar: :full) %> + <%= text_editor_for(f, :description, lines: 8, toolbar: :content) %>
diff --git a/decidim-initiatives/app/views/decidim/initiatives/create_initiative/previous_form.html.erb b/decidim-initiatives/app/views/decidim/initiatives/create_initiative/previous_form.html.erb index c2685f2470061..daf3ff9ecbc0f 100644 --- a/decidim-initiatives/app/views/decidim/initiatives/create_initiative/previous_form.html.erb +++ b/decidim-initiatives/app/views/decidim/initiatives/create_initiative/previous_form.html.erb @@ -27,7 +27,7 @@
- <%= text_editor_for(f, :description, lines: 8, toolbar: :full) %> + <%= text_editor_for(f, :description, lines: 8, toolbar: :content) %>
diff --git a/decidim-initiatives/app/views/decidim/initiatives/initiatives/_form.html.erb b/decidim-initiatives/app/views/decidim/initiatives/initiatives/_form.html.erb index 4aba8552286ab..1d9c4bf74335c 100644 --- a/decidim-initiatives/app/views/decidim/initiatives/initiatives/_form.html.erb +++ b/decidim-initiatives/app/views/decidim/initiatives/initiatives/_form.html.erb @@ -22,7 +22,7 @@
- <%= text_editor_for(form, :description, toolbar: :full, lines: 8, disabled: !allowed_to?(:update, :initiative, initiative: current_initiative), value: translated_attribute(@form.description)) %> + <%= text_editor_for(form, :description, toolbar: :content, lines: 8, disabled: !allowed_to?(:update, :initiative, initiative: current_initiative), value: translated_attribute(@form.description)) %>
diff --git a/decidim-initiatives/spec/system/create_initiative_spec.rb b/decidim-initiatives/spec/system/create_initiative_spec.rb index f3a4647101c9e..0ee6ca5fac23e 100644 --- a/decidim-initiatives/spec/system/create_initiative_spec.rb +++ b/decidim-initiatives/spec/system/create_initiative_spec.rb @@ -206,7 +206,7 @@ find_button("I want to promote this initiative").click end - it_behaves_like "having a rich text editor", "new_initiative_previous_form", "full" + it_behaves_like "having a rich text editor", "new_initiative_previous_form", "content" end describe "creating an initiative" do @@ -442,6 +442,17 @@ expect(page).to have_content("Area") end end + + context "when rich text editor is enabled for participants" do + before do + expect(page).to have_content("Create") + organization.update(rich_text_editor_in_public_views: true) + + visit current_path + end + + it_behaves_like "having a rich text editor", "new_initiative_form", "content" + end end end diff --git a/decidim-initiatives/spec/system/edit_initiative_spec.rb b/decidim-initiatives/spec/system/edit_initiative_spec.rb index fc9bc49ae297d..28f9e9fc0bd7d 100644 --- a/decidim-initiatives/spec/system/edit_initiative_spec.rb +++ b/decidim-initiatives/spec/system/edit_initiative_spec.rb @@ -97,4 +97,19 @@ expect(page).to have_content("not authorized") end end + + context "when rich text editor is enabled for participants" do + let(:initiative) { create(:initiative, :created, author: user, scoped_type: scoped_type, organization: organization) } + let(:organization) { create(:organization, rich_text_editor_in_public_views: true) } + + before do + visit initiative_path + + click_link("Edit", href: edit_initiative_path) + + expect(page).to have_content "EDIT INITIATIVE" + end + + it_behaves_like "having a rich text editor", "edit_initiative", "content" + end end