From 8462b8411f03b5a3761a6d9aae21e4137e798d55 Mon Sep 17 00:00:00 2001 From: Guillaume MORET <90462045+AyakorK@users.noreply.github.com> Date: Mon, 23 Oct 2023 17:51:39 +0200 Subject: [PATCH] fix: Backport fix of disappearance of iframes due to desactivation of decidim cookies (#451) --- config/application.rb | 1 + .../services/decidim/iframe_disabler_extends.rb | 13 +++++++++++++ spec/system/survey_spec.rb | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 lib/extends/services/decidim/iframe_disabler_extends.rb diff --git a/config/application.rb b/config/application.rb index d8c610ee77..03ab7b9a20 100644 --- a/config/application.rb +++ b/config/application.rb @@ -47,6 +47,7 @@ class Application < Rails::Application config.after_initialize do require "extends/controllers/decidim/devise/sessions_controller_extends" require "extends/controllers/decidim/editor_images_controller_extends" + require "extends/services/decidim/iframe_disabler_extends" Decidim::GraphiQL::Rails.config.tap do |config| config.initial_query = "{\n deployment {\n version\n branch\n remote\n upToDate\n currentCommit\n latestCommit\n locallyModified\n }\n}".html_safe diff --git a/lib/extends/services/decidim/iframe_disabler_extends.rb b/lib/extends/services/decidim/iframe_disabler_extends.rb new file mode 100644 index 0000000000..80449c5a36 --- /dev/null +++ b/lib/extends/services/decidim/iframe_disabler_extends.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module IframeDisablerExtends + def perform + @document = Nokogiri::HTML::DocumentFragment.parse(@text) + # disable_iframes(@document) + document.to_html + end +end + +Decidim::IframeDisabler.class_eval do + prepend(IframeDisablerExtends) +end diff --git a/spec/system/survey_spec.rb b/spec/system/survey_spec.rb index 66b0ef6de9..af796e3afc 100644 --- a/spec/system/survey_spec.rb +++ b/spec/system/survey_spec.rb @@ -111,7 +111,7 @@ # click_button "Accept all" expect(page).to have_selector("img[src='#{image_url}']") # With cookie banner iframe is deactivated - # expect(page).to have_selector("iframe[src='#{image_url}']") + expect(page).to have_selector("iframe[src='#{image_url}']") end end