From 0952174efeb09530c7ba6063876abd8f1d153fc2 Mon Sep 17 00:00:00 2001 From: barbara oliveira Date: Wed, 17 Apr 2024 17:10:37 +0200 Subject: [PATCH 01/12] test:update conference registration system test --- .../spec/controllers/conferences_controller_spec.rb | 2 +- .../spec/system/conference_registrations_spec.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/decidim-conferences/spec/controllers/conferences_controller_spec.rb b/decidim-conferences/spec/controllers/conferences_controller_spec.rb index db9c6fd7c453..39a93387e002 100644 --- a/decidim-conferences/spec/controllers/conferences_controller_spec.rb +++ b/decidim-conferences/spec/controllers/conferences_controller_spec.rb @@ -4,7 +4,7 @@ module Decidim module Conferences - describe ConferencesController do + describe RegistrationTypesControllerController do routes { Decidim::Conferences::Engine.routes } let(:organization) { create(:organization) } diff --git a/decidim-conferences/spec/system/conference_registrations_spec.rb b/decidim-conferences/spec/system/conference_registrations_spec.rb index 04e6cddd372b..939ec19800cb 100644 --- a/decidim-conferences/spec/system/conference_registrations_spec.rb +++ b/decidim-conferences/spec/system/conference_registrations_spec.rb @@ -127,6 +127,19 @@ def visit_conference_registration_type expect(page).to have_css("button[disabled]", text: "Registration", count: 4) end end + + context "and there is no registrations types" do + let!(:registration_types) { [] } + + it "allows to register" do + visit_conference + within ".conference__hero" do + expect(page).to have_content "Register" + click_on "Register" + expect(page).to have_content "CHOOSE YOUR REGISTRATION OPTION:" + end + end + end end context "and the user is going to the conference" do From 3515950d77ac17d75e2f5abe1fc00e4600e152cd Mon Sep 17 00:00:00 2001 From: stephanie rousset Date: Wed, 17 Apr 2024 17:26:48 +0200 Subject: [PATCH 02/12] test: add registration_types controller test --- .../registration_types_controller_spec.rb | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 decidim-conferences/spec/controllers/registration_types_controller_spec.rb diff --git a/decidim-conferences/spec/controllers/registration_types_controller_spec.rb b/decidim-conferences/spec/controllers/registration_types_controller_spec.rb new file mode 100644 index 000000000000..491e3f0b3538 --- /dev/null +++ b/decidim-conferences/spec/controllers/registration_types_controller_spec.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +require "spec_helper" + +module Decidim + module Conferences + describe RegistrationTypesController do + routes { Decidim::Conferences::Engine.routes } + + let(:organization) { create(:organization) } + let!(:conference) do + create( + :conference, + :published, + registrations_enabled:, + organization: + ) + end + let(:registrations_enabled) { true } + let(:registration_types_count) { 5 } + let!(:registration_types) do + create_list(:registration_type, registration_types_count, conference:) + end + let(:registration_type) { registration_types.first } + + before do + request.env["decidim.current_organization"] = organization + end + + describe "index" do + context "when registration_types is present" do + it "does not raise an error" do + get :index, params: { conference_slug: conference.slug } + assert_response :success + end + end + + context "when registration_types is empty" do + let(:registration_types) { nil } + context "and current_participatory_space registrations is enabled" do + it "does raise an error" do + expect { get :index, params: { conference_slug: conference.slug } } + .to raise_error(ActionController::RoutingError) + end + end + + context "and current_participatory_space registrations is disabled" do + let(:registrations_enabled) { false } + + it "does not raise an error" do + get :index, params: { conference_slug: conference.slug } + assert_response :success + end + end + end + end + end + end +end From 10f23540674de5e007f5cb255cea4ad2c574a5af Mon Sep 17 00:00:00 2001 From: stephanie rousset Date: Wed, 17 Apr 2024 18:06:44 +0200 Subject: [PATCH 03/12] fix: conference registration_types controller index --- .../decidim/conferences/registration_types_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decidim-conferences/app/controllers/decidim/conferences/registration_types_controller.rb b/decidim-conferences/app/controllers/decidim/conferences/registration_types_controller.rb index ba86d4e85a44..a12c4ecaa1ab 100644 --- a/decidim-conferences/app/controllers/decidim/conferences/registration_types_controller.rb +++ b/decidim-conferences/app/controllers/decidim/conferences/registration_types_controller.rb @@ -8,7 +8,7 @@ class RegistrationTypesController < Decidim::Conferences::ApplicationController helper_method :collection, :conference def index - raise ActionController::RoutingError, "No registration types for this conference " if registration_types.empty? && current_participatory_space.registrations_enabled.empty? + raise ActionController::RoutingError, "No registration types for this conference " if registration_types.empty? && current_participatory_space.registrations_enabled enforce_permission_to :list, :registration_types end From 5a3bb1f9c5dae4d45d4a92b35a326a491a0ced97 Mon Sep 17 00:00:00 2001 From: stephanie rousset Date: Thu, 18 Apr 2024 09:58:40 +0200 Subject: [PATCH 04/12] correction after PR review --- .../spec/controllers/conferences_controller_spec.rb | 2 +- .../spec/controllers/registration_types_controller_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/decidim-conferences/spec/controllers/conferences_controller_spec.rb b/decidim-conferences/spec/controllers/conferences_controller_spec.rb index 39a93387e002..db9c6fd7c453 100644 --- a/decidim-conferences/spec/controllers/conferences_controller_spec.rb +++ b/decidim-conferences/spec/controllers/conferences_controller_spec.rb @@ -4,7 +4,7 @@ module Decidim module Conferences - describe RegistrationTypesControllerController do + describe ConferencesController do routes { Decidim::Conferences::Engine.routes } let(:organization) { create(:organization) } diff --git a/decidim-conferences/spec/controllers/registration_types_controller_spec.rb b/decidim-conferences/spec/controllers/registration_types_controller_spec.rb index 491e3f0b3538..c2c5bdd3d7c2 100644 --- a/decidim-conferences/spec/controllers/registration_types_controller_spec.rb +++ b/decidim-conferences/spec/controllers/registration_types_controller_spec.rb @@ -21,7 +21,6 @@ module Conferences let!(:registration_types) do create_list(:registration_type, registration_types_count, conference:) end - let(:registration_type) { registration_types.first } before do request.env["decidim.current_organization"] = organization @@ -36,7 +35,8 @@ module Conferences end context "when registration_types is empty" do - let(:registration_types) { nil } + let(:registration_types) { [] } + context "and current_participatory_space registrations is enabled" do it "does raise an error" do expect { get :index, params: { conference_slug: conference.slug } } From 6f092fe0c1acf68ce9ab7c3bf71e7bc6fa72f84d Mon Sep 17 00:00:00 2001 From: stephanierousset <61418966+Stef-Rousset@users.noreply.github.com> Date: Fri, 19 Apr 2024 16:14:55 +0200 Subject: [PATCH 05/12] fix: hide register button in conference when no registration types (#1221) * fix: hide register button in conference when no registration types * lint: add missing space in conference show view page --- .../conferences/_conference_hero.html.erb | 2 +- .../conferences/conferences/show.html.erb | 8 +++++--- .../system/conference_registrations_spec.rb | 17 +++++++++++++---- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/decidim-conferences/app/views/decidim/conferences/conferences/_conference_hero.html.erb b/decidim-conferences/app/views/decidim/conferences/conferences/_conference_hero.html.erb index e939ee53bad1..b2e617f920ae 100644 --- a/decidim-conferences/app/views/decidim/conferences/conferences/_conference_hero.html.erb +++ b/decidim-conferences/app/views/decidim/conferences/conferences/_conference_hero.html.erb @@ -19,7 +19,7 @@ <% if current_participatory_space.registrations_enabled? %> <% if current_participatory_space.has_registration_for?(current_user) %> <%= link_to t("layouts.decidim.conference_hero.manage_registration"), decidim_conferences.conference_registration_types_path(current_participatory_space), class: "button button__lg button__primary" %> - <% else %> + <% elsif current_participatory_space.registration_types.present? %> <%= link_to t("layouts.decidim.conference_hero.register"), decidim_conferences.conference_registration_types_path(current_participatory_space), class: "button button__lg button__secondary" %> <% end %> <% end %> diff --git a/decidim-conferences/app/views/decidim/conferences/conferences/show.html.erb b/decidim-conferences/app/views/decidim/conferences/conferences/show.html.erb index bf297f427de7..9eeb76bdc6e1 100644 --- a/decidim-conferences/app/views/decidim/conferences/conferences/show.html.erb +++ b/decidim-conferences/app/views/decidim/conferences/conferences/show.html.erb @@ -58,7 +58,7 @@ edit_link( <% if current_participatory_space.registrations_enabled? %> <% if current_participatory_space.has_registration_for?(current_user) %> <%= link_to t("decidim.conferences.conferences.show.manage_registration"), decidim_conferences.conference_registration_types_path(current_participatory_space), class: "button button__lg button__primary" %> - <% else %> + <% elsif current_participatory_space.registration_types.present? %> <%= link_to t("decidim.conferences.conferences.show.register"), decidim_conferences.conference_registration_types_path(current_participatory_space), class: "button button__lg button__secondary" %> <% end %> <% end %> @@ -85,7 +85,9 @@ edit_link( <% if current_participatory_space.registrations_enabled? %>
-

<%= t("decidim.conferences.conferences.show.register") %>

+ <% if current_participatory_space.registration_types.present? %> +

<%= t("decidim.conferences.conferences.show.register") %>

+ <% end %> <% if current_user.present? %>
@@ -96,7 +98,7 @@ edit_link(
<% if current_participatory_space.has_registration_for?(current_user) %> <%= link_to t("decidim.conferences.conferences.show.manage_registration"), decidim_conferences.conference_registration_types_path(current_participatory_space), class: "button button__lg button__primary" %> - <% else %> + <% elsif current_participatory_space.registration_types.present? %> <%= link_to t("decidim.conferences.conferences.show.register"), decidim_conferences.conference_registration_types_path(current_participatory_space), class: "button button__lg button__secondary" %> <% end %>
diff --git a/decidim-conferences/spec/system/conference_registrations_spec.rb b/decidim-conferences/spec/system/conference_registrations_spec.rb index 939ec19800cb..486776ef27b4 100644 --- a/decidim-conferences/spec/system/conference_registrations_spec.rb +++ b/decidim-conferences/spec/system/conference_registrations_spec.rb @@ -128,15 +128,24 @@ def visit_conference_registration_type end end - context "and there is no registrations types" do - let!(:registration_types) { [] } - + context "and there is registrations types" do it "allows to register" do visit_conference within ".conference__hero" do expect(page).to have_content "Register" click_on "Register" - expect(page).to have_content "CHOOSE YOUR REGISTRATION OPTION:" + end + expect(page).to have_content "CHOOSE YOUR REGISTRATION OPTION:" + end + end + + context "and there is no registrations types" do + let(:registration_types) { [] } + + it "does not show register button" do + visit_conference + within ".conference__hero" do + expect(page).to have_no_content "Register" end end end From 59804f1bb9e735a6f9f221af87eeb06d750553b1 Mon Sep 17 00:00:00 2001 From: barbara oliveira Date: Wed, 24 Apr 2024 11:57:54 +0200 Subject: [PATCH 06/12] fix: add has_published_registration_types? method to conference model --- decidim-conferences/app/models/decidim/conference.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/decidim-conferences/app/models/decidim/conference.rb b/decidim-conferences/app/models/decidim/conference.rb index 1133c5c18dc7..936ceefa7262 100644 --- a/decidim-conferences/app/models/decidim/conference.rb +++ b/decidim-conferences/app/models/decidim/conference.rb @@ -113,6 +113,12 @@ def has_available_slots? available_slots > conference_registrations.count end + def has_published_registration_types? + return false if registration_types.empty? + + registration_types.any?(&:published_at?) + end + def remaining_slots available_slots - conference_registrations.count end From 42befd3a389855f65ec65d2bcf12357289348832 Mon Sep 17 00:00:00 2001 From: barbara oliveira Date: Wed, 24 Apr 2024 16:52:48 +0200 Subject: [PATCH 07/12] fix: add rspec for has_published_registration_types? method --- .../spec/models/decidim/conference_spec.rb | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/decidim-conferences/spec/models/decidim/conference_spec.rb b/decidim-conferences/spec/models/decidim/conference_spec.rb index a72a0c06678c..53b3cd2cc9d3 100644 --- a/decidim-conferences/spec/models/decidim/conference_spec.rb +++ b/decidim-conferences/spec/models/decidim/conference_spec.rb @@ -28,5 +28,33 @@ module Decidim it { is_expected.to be_valid } end + + describe "#has_published_registration_types?" do + context "when conference has no registration type" do + it "returns false" do + expect(conference.has_published_registration_types?).to be_falsey + end + end + + context "when conference has registration types" do + let!(:registration_types) do + create_list(:registration_type, 5, conference:) + end + + it "return true" do + expect(conference.has_published_registration_types?).to be_truthy + end + + context "and the registration types are unpublished" do + let!(:registration_types) do + create_list(:registration_type, 5, :unpublished, conference:) + end + + it "returns false" do + expect(conference.has_published_registration_types?).to be_falsey + end + end + end + end end end From 7d42432eafff6478d242867ad9578a616cf74685 Mon Sep 17 00:00:00 2001 From: barbara oliveira Date: Wed, 24 Apr 2024 16:56:00 +0200 Subject: [PATCH 08/12] lint: fix with rubocop --- decidim-conferences/spec/models/decidim/conference_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/decidim-conferences/spec/models/decidim/conference_spec.rb b/decidim-conferences/spec/models/decidim/conference_spec.rb index 53b3cd2cc9d3..11772bd62f5c 100644 --- a/decidim-conferences/spec/models/decidim/conference_spec.rb +++ b/decidim-conferences/spec/models/decidim/conference_spec.rb @@ -32,7 +32,7 @@ module Decidim describe "#has_published_registration_types?" do context "when conference has no registration type" do it "returns false" do - expect(conference.has_published_registration_types?).to be_falsey + expect(conference).not_to have_published_registration_types end end @@ -42,7 +42,7 @@ module Decidim end it "return true" do - expect(conference.has_published_registration_types?).to be_truthy + expect(conference).to have_published_registration_types end context "and the registration types are unpublished" do @@ -51,7 +51,7 @@ module Decidim end it "returns false" do - expect(conference.has_published_registration_types?).to be_falsey + expect(conference).not_to have_published_registration_types end end end From 7d34ea61a7f021f0654d1dfa41223f42c4a88add Mon Sep 17 00:00:00 2001 From: barbara oliveira Date: Wed, 24 Apr 2024 17:53:41 +0200 Subject: [PATCH 09/12] refacto --- .../spec/models/decidim/conference_spec.rb | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/decidim-conferences/spec/models/decidim/conference_spec.rb b/decidim-conferences/spec/models/decidim/conference_spec.rb index 11772bd62f5c..f3797a4748b4 100644 --- a/decidim-conferences/spec/models/decidim/conference_spec.rb +++ b/decidim-conferences/spec/models/decidim/conference_spec.rb @@ -30,10 +30,10 @@ module Decidim end describe "#has_published_registration_types?" do + subject { conference.has_published_registration_types? } + context "when conference has no registration type" do - it "returns false" do - expect(conference).not_to have_published_registration_types - end + it { is_expected.to be_falsey } end context "when conference has registration types" do @@ -41,18 +41,14 @@ module Decidim create_list(:registration_type, 5, conference:) end - it "return true" do - expect(conference).to have_published_registration_types - end + it { is_expected.to be_truthy } context "and the registration types are unpublished" do let!(:registration_types) do create_list(:registration_type, 5, :unpublished, conference:) end - it "returns false" do - expect(conference).not_to have_published_registration_types - end + it { is_expected.to be_falsey } end end end From 6667e4dffdcd2effddf2c68a7cbeb4d6fff4383c Mon Sep 17 00:00:00 2001 From: stephanie rousset Date: Thu, 25 Apr 2024 10:12:51 +0200 Subject: [PATCH 10/12] fix: update views and system tests after change request --- .../conferences/_conference_hero.html.erb | 2 +- .../conferences/conferences/show.html.erb | 6 ++--- .../system/conference_registrations_spec.rb | 22 ++++++++++++++++++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/decidim-conferences/app/views/decidim/conferences/conferences/_conference_hero.html.erb b/decidim-conferences/app/views/decidim/conferences/conferences/_conference_hero.html.erb index b2e617f920ae..a974d508e2ee 100644 --- a/decidim-conferences/app/views/decidim/conferences/conferences/_conference_hero.html.erb +++ b/decidim-conferences/app/views/decidim/conferences/conferences/_conference_hero.html.erb @@ -19,7 +19,7 @@ <% if current_participatory_space.registrations_enabled? %> <% if current_participatory_space.has_registration_for?(current_user) %> <%= link_to t("layouts.decidim.conference_hero.manage_registration"), decidim_conferences.conference_registration_types_path(current_participatory_space), class: "button button__lg button__primary" %> - <% elsif current_participatory_space.registration_types.present? %> + <% elsif current_participatory_space.has_published_registration_types? %> <%= link_to t("layouts.decidim.conference_hero.register"), decidim_conferences.conference_registration_types_path(current_participatory_space), class: "button button__lg button__secondary" %> <% end %> <% end %> diff --git a/decidim-conferences/app/views/decidim/conferences/conferences/show.html.erb b/decidim-conferences/app/views/decidim/conferences/conferences/show.html.erb index 9eeb76bdc6e1..b84671c8a8e3 100644 --- a/decidim-conferences/app/views/decidim/conferences/conferences/show.html.erb +++ b/decidim-conferences/app/views/decidim/conferences/conferences/show.html.erb @@ -58,7 +58,7 @@ edit_link( <% if current_participatory_space.registrations_enabled? %> <% if current_participatory_space.has_registration_for?(current_user) %> <%= link_to t("decidim.conferences.conferences.show.manage_registration"), decidim_conferences.conference_registration_types_path(current_participatory_space), class: "button button__lg button__primary" %> - <% elsif current_participatory_space.registration_types.present? %> + <% elsif current_participatory_space.has_published_registration_types? %> <%= link_to t("decidim.conferences.conferences.show.register"), decidim_conferences.conference_registration_types_path(current_participatory_space), class: "button button__lg button__secondary" %> <% end %> <% end %> @@ -85,7 +85,7 @@ edit_link( <% if current_participatory_space.registrations_enabled? %>
- <% if current_participatory_space.registration_types.present? %> + <% if current_participatory_space.has_published_registration_types? %>

<%= t("decidim.conferences.conferences.show.register") %>

<% end %> <% if current_user.present? %> @@ -98,7 +98,7 @@ edit_link(
<% if current_participatory_space.has_registration_for?(current_user) %> <%= link_to t("decidim.conferences.conferences.show.manage_registration"), decidim_conferences.conference_registration_types_path(current_participatory_space), class: "button button__lg button__primary" %> - <% elsif current_participatory_space.registration_types.present? %> + <% elsif current_participatory_space.has_published_registration_types? %> <%= link_to t("decidim.conferences.conferences.show.register"), decidim_conferences.conference_registration_types_path(current_participatory_space), class: "button button__lg button__secondary" %> <% end %>
diff --git a/decidim-conferences/spec/system/conference_registrations_spec.rb b/decidim-conferences/spec/system/conference_registrations_spec.rb index 486776ef27b4..e9010d0802bf 100644 --- a/decidim-conferences/spec/system/conference_registrations_spec.rb +++ b/decidim-conferences/spec/system/conference_registrations_spec.rb @@ -128,17 +128,34 @@ def visit_conference_registration_type end end - context "and there is registrations types" do + context "and there is published registrations types" do it "allows to register" do visit_conference within ".conference__hero" do expect(page).to have_content "Register" + end + within ".conference__content-block" do + expect(page).to have_content "Register" click_on "Register" end expect(page).to have_content "CHOOSE YOUR REGISTRATION OPTION:" end end + context "and there is unpublished registrations types" do + let(:registration_types) { :unpublished } + + it "does not show register button" do + visit_conference + within ".conference__hero" do + expect(page).to have_no_content "Register" + end + within ".conference__content-block" do + expect(page).to have_no_content "Register" + end + end + end + context "and there is no registrations types" do let(:registration_types) { [] } @@ -147,6 +164,9 @@ def visit_conference_registration_type within ".conference__hero" do expect(page).to have_no_content "Register" end + within ".conference__content-block" do + expect(page).to have_no_content "Register" + end end end end From 9f0fcaf26a0006e9dcb6a4916b7d6e6be3b24eac Mon Sep 17 00:00:00 2001 From: stephanie rousset Date: Thu, 25 Apr 2024 11:23:03 +0200 Subject: [PATCH 11/12] fix: update system spec after review --- .../spec/system/conference_registrations_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/decidim-conferences/spec/system/conference_registrations_spec.rb b/decidim-conferences/spec/system/conference_registrations_spec.rb index e9010d0802bf..bd99c8b3885c 100644 --- a/decidim-conferences/spec/system/conference_registrations_spec.rb +++ b/decidim-conferences/spec/system/conference_registrations_spec.rb @@ -143,7 +143,9 @@ def visit_conference_registration_type end context "and there is unpublished registrations types" do - let(:registration_types) { :unpublished } + let!(:registration_types) do + create_list(:registration_type, 5, :unpublished, conference:) + end it "does not show register button" do visit_conference From 6db19611e084b687430af2d0ea5f9813c062d153 Mon Sep 17 00:00:00 2001 From: stephanierousset <61418966+Stef-Rousset@users.noreply.github.com> Date: Thu, 25 Apr 2024 17:08:57 +0200 Subject: [PATCH 12/12] style: update context sentences in system test (#1223) --- .../spec/system/conference_registrations_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/decidim-conferences/spec/system/conference_registrations_spec.rb b/decidim-conferences/spec/system/conference_registrations_spec.rb index bd99c8b3885c..1cf9cee023d2 100644 --- a/decidim-conferences/spec/system/conference_registrations_spec.rb +++ b/decidim-conferences/spec/system/conference_registrations_spec.rb @@ -128,7 +128,7 @@ def visit_conference_registration_type end end - context "and there is published registrations types" do + context "and there are published registrations types" do it "allows to register" do visit_conference within ".conference__hero" do @@ -142,12 +142,12 @@ def visit_conference_registration_type end end - context "and there is unpublished registrations types" do + context "and there are unpublished registrations types" do let!(:registration_types) do create_list(:registration_type, 5, :unpublished, conference:) end - it "does not show register button" do + it "does not show the register button" do visit_conference within ".conference__hero" do expect(page).to have_no_content "Register" @@ -158,10 +158,10 @@ def visit_conference_registration_type end end - context "and there is no registrations types" do + context "and there are no registrations types" do let(:registration_types) { [] } - it "does not show register button" do + it "does not show the register button" do visit_conference within ".conference__hero" do expect(page).to have_no_content "Register"