Skip to content

Commit

Permalink
fix: Add Change request suggestions
Browse files Browse the repository at this point in the history
Conference registering change requests
  • Loading branch information
Quentinchampenois authored Apr 25, 2024
2 parents 6f092fe + 9f0fcaf commit cf08f85
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 5 deletions.
6 changes: 6 additions & 0 deletions decidim-conferences/app/models/decidim/conference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand All @@ -85,7 +85,7 @@ edit_link(

<% if current_participatory_space.registrations_enabled? %>
<section class="content-block">
<% if current_participatory_space.registration_types.present? %>
<% if current_participatory_space.has_published_registration_types? %>
<h2 class="h2 decorator"><%= t("decidim.conferences.conferences.show.register") %></h2>
<% end %>
<% if current_user.present? %>
Expand All @@ -98,7 +98,7 @@ edit_link(
<div>
<% 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 %>
</div>
Expand Down
24 changes: 24 additions & 0 deletions decidim-conferences/spec/models/decidim/conference_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,29 @@ module Decidim

it { is_expected.to be_valid }
end

describe "#has_published_registration_types?" do
subject { conference.has_published_registration_types? }

context "when conference has no registration type" do
it { is_expected.to be_falsey }
end

context "when conference has registration types" do
let!(:registration_types) do
create_list(:registration_type, 5, conference:)
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 { is_expected.to be_falsey }
end
end
end
end
end
24 changes: 23 additions & 1 deletion decidim-conferences/spec/system/conference_registrations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,36 @@ 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) do
create_list(:registration_type, 5, :unpublished, conference:)
end

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) { [] }

Expand All @@ -147,6 +166,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
Expand Down

0 comments on commit cf08f85

Please sign in to comment.