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] 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 e939ee53bad11..b2e617f920aeb 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 bf297f427de72..9eeb76bdc6e17 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 939ec19800cb5..486776ef27b48 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