From 470ddac86a62e72f69ef1b23c1dcf874f2bf20cf Mon Sep 17 00:00:00 2001 From: Harrison Hassig Date: Tue, 6 Aug 2024 12:24:12 +0200 Subject: [PATCH 01/10] Fix conference view to allow images from admin and spec file --- .../conferences/conferences/show.html.erb | 4 ++-- spec/system/conferences_with_image_spec.rb | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 spec/system/conferences_with_image_spec.rb diff --git a/app/views/decidim/conferences/conferences/show.html.erb b/app/views/decidim/conferences/conferences/show.html.erb index f228280..bfcb920 100644 --- a/app/views/decidim/conferences/conferences/show.html.erb +++ b/app/views/decidim/conferences/conferences/show.html.erb @@ -20,12 +20,12 @@ edit_link(

<%= t("conferences.show.introduction", scope: "decidim") %>

- <%= decidim_sanitize translated_attribute(current_participatory_space.short_description) %> + <%= decidim_sanitize_editor_admin translated_attribute(current_participatory_space.short_description) %>

<%= t("conferences.show.details", scope: "decidim") %>

- <%= decidim_sanitize translated_attribute(current_participatory_space.description) %> + <%= decidim_sanitize_editor_admin translated_attribute(current_participatory_space.description) %>
<% if current_participatory_space.registrations_enabled? %> diff --git a/spec/system/conferences_with_image_spec.rb b/spec/system/conferences_with_image_spec.rb new file mode 100644 index 0000000..bb90688 --- /dev/null +++ b/spec/system/conferences_with_image_spec.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +require "rails_helper" + +describe "conference with images", type: :system do + let!(:organization) { create :organization } + let!(:conference) { create :conference, organization: organization, slug: slug, registrations_enabled: true } + let(:slug) { "bla-bla" } + let(:user) { create(:user, :confirmed, organization: organization) } + + before do + visit_component + page.execute_script("$('#dc-modal-accept').click()") + visit Decidim::ResourceLocatorPresenter.new(post).path + end + + it "shows the image" do + expect(page).to have_selector('img src=') + end +end From 93957e35d3308ca3c09ef59679445b5746cec502 Mon Sep 17 00:00:00 2001 From: Harrison Hassig Date: Tue, 6 Aug 2024 14:08:21 +0200 Subject: [PATCH 02/10] fix quotations to satisfy rspec --- spec/system/conferences_with_image_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/system/conferences_with_image_spec.rb b/spec/system/conferences_with_image_spec.rb index bb90688..0f0dc66 100644 --- a/spec/system/conferences_with_image_spec.rb +++ b/spec/system/conferences_with_image_spec.rb @@ -15,6 +15,6 @@ end it "shows the image" do - expect(page).to have_selector('img src=') + expect(page).to have_selector("img src=") end end From ee86833933f03c7021f0be18ac9aa9294eca9055 Mon Sep 17 00:00:00 2001 From: Harrison Hassig Date: Tue, 6 Aug 2024 16:08:28 +0200 Subject: [PATCH 03/10] Fix rspec require in factories --- spec/factories.rb | 1 + spec/system/conferences_with_image_spec.rb | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/factories.rb b/spec/factories.rb index 66c8dbf..df5f116 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -3,3 +3,4 @@ require "decidim/core/test/factories" require "decidim/proposals/test/factories" require "decidim/decidim_awesome/test/factories" +require "decidim/conferences/test/factories" diff --git a/spec/system/conferences_with_image_spec.rb b/spec/system/conferences_with_image_spec.rb index 0f0dc66..33726f1 100644 --- a/spec/system/conferences_with_image_spec.rb +++ b/spec/system/conferences_with_image_spec.rb @@ -1,8 +1,9 @@ # frozen_string_literal: true require "rails_helper" +require "decidim/conferences/test/factories" -describe "conference with images", type: :system do +describe "Conference with images", type: :system, perform_enqueued: true do let!(:organization) { create :organization } let!(:conference) { create :conference, organization: organization, slug: slug, registrations_enabled: true } let(:slug) { "bla-bla" } @@ -11,10 +12,10 @@ before do visit_component page.execute_script("$('#dc-modal-accept').click()") - visit Decidim::ResourceLocatorPresenter.new(post).path + page.visit "/conferences/bla-bla" end it "shows the image" do - expect(page).to have_selector("img src=") + expect(page).to have_selector("img") end end From c78255359f18cfdbc7fa449bd7caf98850691595 Mon Sep 17 00:00:00 2001 From: Harrison Hassig Date: Wed, 7 Aug 2024 10:03:20 +0200 Subject: [PATCH 04/10] visit_component has component to visit --- spec/system/conferences_with_image_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/system/conferences_with_image_spec.rb b/spec/system/conferences_with_image_spec.rb index 33726f1..3499bb8 100644 --- a/spec/system/conferences_with_image_spec.rb +++ b/spec/system/conferences_with_image_spec.rb @@ -3,10 +3,12 @@ require "rails_helper" require "decidim/conferences/test/factories" -describe "Conference with images", type: :system, perform_enqueued: true do +describe "Conference with images", type: :system do + include_context "with a component" let!(:organization) { create :organization } - let!(:conference) { create :conference, organization: organization, slug: slug, registrations_enabled: true } let(:slug) { "bla-bla" } + let(:body) { { en: "

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

" } } + let!(:conference) { create :conference, organization: organization, slug: slug, registrations_enabled: true, component: component, body: body } let(:user) { create(:user, :confirmed, organization: organization) } before do From c1bf799f21de30496ddc847a2b3d7e642903f2de Mon Sep 17 00:00:00 2001 From: Harrison Hassig Date: Wed, 7 Aug 2024 10:06:43 +0200 Subject: [PATCH 05/10] Create short_description to host the img tag --- spec/system/conferences_with_image_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/system/conferences_with_image_spec.rb b/spec/system/conferences_with_image_spec.rb index 3499bb8..607f7b3 100644 --- a/spec/system/conferences_with_image_spec.rb +++ b/spec/system/conferences_with_image_spec.rb @@ -7,8 +7,8 @@ include_context "with a component" let!(:organization) { create :organization } let(:slug) { "bla-bla" } - let(:body) { { en: "

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

" } } - let!(:conference) { create :conference, organization: organization, slug: slug, registrations_enabled: true, component: component, body: body } + let(:short_description) { { en: "

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

" } } + let!(:conference) { create :conference, organization: organization, slug: slug, registrations_enabled: true, component: component, short_description: short_description } let(:user) { create(:user, :confirmed, organization: organization) } before do From afe31ce2aab0abcf34da7e6b4cd869b67ac62114 Mon Sep 17 00:00:00 2001 From: Harrison Hassig Date: Wed, 7 Aug 2024 10:14:30 +0200 Subject: [PATCH 06/10] include manifest name as conferences --- spec/system/conferences_with_image_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/system/conferences_with_image_spec.rb b/spec/system/conferences_with_image_spec.rb index 607f7b3..336b36e 100644 --- a/spec/system/conferences_with_image_spec.rb +++ b/spec/system/conferences_with_image_spec.rb @@ -5,6 +5,7 @@ describe "Conference with images", type: :system do include_context "with a component" + let(:manifest_name) { "conferences" } let!(:organization) { create :organization } let(:slug) { "bla-bla" } let(:short_description) { { en: "

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

" } } From 5b77739fae5e263ccbbf2f6ea987d15c21847fd2 Mon Sep 17 00:00:00 2001 From: Harrison Hassig Date: Thu, 8 Aug 2024 13:58:33 +0200 Subject: [PATCH 07/10] :conferences as manifest_name --- spec/system/conferences_with_image_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/system/conferences_with_image_spec.rb b/spec/system/conferences_with_image_spec.rb index 336b36e..91cf73e 100644 --- a/spec/system/conferences_with_image_spec.rb +++ b/spec/system/conferences_with_image_spec.rb @@ -5,11 +5,11 @@ describe "Conference with images", type: :system do include_context "with a component" - let(:manifest_name) { "conferences" } - let!(:organization) { create :organization } + let(:organization) { create :organization } + let(:manifest_name) { :conferences } let(:slug) { "bla-bla" } let(:short_description) { { en: "

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

" } } - let!(:conference) { create :conference, organization: organization, slug: slug, registrations_enabled: true, component: component, short_description: short_description } + let(:conference) { create :conference, organization: organization, slug: slug, registrations_enabled: true, component: component, short_description: short_description } let(:user) { create(:user, :confirmed, organization: organization) } before do From c025434e9ec12e047496ab63779402bd826f6e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Bol=C3=ADvar?= Date: Mon, 12 Aug 2024 12:27:56 +0200 Subject: [PATCH 08/10] Fix some problems in the spec --- spec/system/conferences_with_image_spec.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/spec/system/conferences_with_image_spec.rb b/spec/system/conferences_with_image_spec.rb index 91cf73e..97e0d57 100644 --- a/spec/system/conferences_with_image_spec.rb +++ b/spec/system/conferences_with_image_spec.rb @@ -1,21 +1,15 @@ # frozen_string_literal: true require "rails_helper" -require "decidim/conferences/test/factories" describe "Conference with images", type: :system do - include_context "with a component" let(:organization) { create :organization } - let(:manifest_name) { :conferences } - let(:slug) { "bla-bla" } let(:short_description) { { en: "

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

" } } - let(:conference) { create :conference, organization: organization, slug: slug, registrations_enabled: true, component: component, short_description: short_description } - let(:user) { create(:user, :confirmed, organization: organization) } + let(:conference) { create :conference, organization: organization, short_description: short_description } before do - visit_component - page.execute_script("$('#dc-modal-accept').click()") - page.visit "/conferences/bla-bla" + switch_to_host(organization.host) + page.visit "/conferences/#{conference.slug}" end it "shows the image" do From 7a6f684fc6d85ecdf10e5e8cadaaafd68f149520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Bol=C3=ADvar?= Date: Mon, 12 Aug 2024 12:41:16 +0200 Subject: [PATCH 09/10] WIP: Remove img --- spec/system/conferences_with_image_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/system/conferences_with_image_spec.rb b/spec/system/conferences_with_image_spec.rb index 97e0d57..f52e308 100644 --- a/spec/system/conferences_with_image_spec.rb +++ b/spec/system/conferences_with_image_spec.rb @@ -4,8 +4,8 @@ describe "Conference with images", type: :system do let(:organization) { create :organization } - let(:short_description) { { en: "

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

" } } - let(:conference) { create :conference, organization: organization, short_description: short_description } + let(:short_description) { { en: "

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

" } } + let!(:conference) { create :conference, organization: organization, short_description: short_description } before do switch_to_host(organization.host) From 4b122d788f29ad713b10f969bacf7910df97a229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Bol=C3=ADvar?= Date: Mon, 12 Aug 2024 13:01:47 +0200 Subject: [PATCH 10/10] Fix test --- spec/system/conferences_with_image_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/system/conferences_with_image_spec.rb b/spec/system/conferences_with_image_spec.rb index f52e308..3820fe5 100644 --- a/spec/system/conferences_with_image_spec.rb +++ b/spec/system/conferences_with_image_spec.rb @@ -4,7 +4,7 @@ describe "Conference with images", type: :system do let(:organization) { create :organization } - let(:short_description) { { en: "

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

" } } + let(:short_description) { { en: "

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

" } } let!(:conference) { create :conference, organization: organization, short_description: short_description } before do @@ -13,6 +13,8 @@ end it "shows the image" do - expect(page).to have_selector("img") + within "#content" do + expect(page).to have_xpath("//img[contains(@src,'favicon.ico')]") + end end end