From 3f7395fa19d12c77e4650f12a0522eaf238e4956 Mon Sep 17 00:00:00 2001 From: decabeza Date: Tue, 3 Apr 2018 19:17:17 +0200 Subject: [PATCH] Adds message on polls index if there are no open polls --- app/views/polls/index.html.erb | 36 ++++++++++++++++++------------- config/locales/en/general.yml | 1 + config/locales/es/general.yml | 1 + spec/features/polls/polls_spec.rb | 3 +++ 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/app/views/polls/index.html.erb b/app/views/polls/index.html.erb index 6877cd31d..7f905491f 100644 --- a/app/views/polls/index.html.erb +++ b/app/views/polls/index.html.erb @@ -9,24 +9,30 @@
<%= render 'shared/filter_subnav', i18n_namespace: "polls.index" %> - <% polls_by_geozone_restriction = @polls.group_by(&:geozone_restricted) %> + <% if @polls.any? %> + <% polls_by_geozone_restriction = @polls.group_by(&:geozone_restricted) %> - <% if polls_by_geozone_restriction[false].present? %> -

- <%= t("polls.index.no_geozone_restricted") %> -

- <%= render partial: 'poll_group', locals: {poll_group: polls_by_geozone_restriction[false]} %> + <% if polls_by_geozone_restriction[false].present? %> +

+ <%= t("polls.index.no_geozone_restricted") %> +

+ <%= render partial: 'poll_group', locals: {poll_group: polls_by_geozone_restriction[false]} %> + <% end %> + + <% if polls_by_geozone_restriction[true].present? %> +

+ <%= t("polls.index.geozone_restricted") %> +

+ <%= render partial: 'poll_group', locals: {poll_group: polls_by_geozone_restriction[true]} %> + <% end %> + + <%= paginate @polls %> + <% else %> +
+ <%= t("polls.index.no_polls") %> +
<% end %> - <% if polls_by_geozone_restriction[true].present? %> -

- <%= t("polls.index.geozone_restricted") %> -

- <%= render partial: 'poll_group', locals: {poll_group: polls_by_geozone_restriction[true]} %> - <% end %> - - <%= paginate @polls %> -

<%= t("polls.index.section_footer.title") %> diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index 1a22db1b1..aa2c0de16 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -487,6 +487,7 @@ en: description: Sign up to vote on citizen proposals and questions the City Council ask to the neighbors. Make municipal decisions directly. help_text_1: "Voting takes place when a citizen proposal supports reaches 1% of the census with voting rights. Voting can also include questions that the City Council ask to the citizens decision." help_text_2: "To participate in the next vote you have to sign up on %{org} and verify your account. All registered voters in the city over 16 years old can vote. The results of all votes are binding on the government." + no_polls: "There are no open votings." show: already_voted_in_booth: "You have already participated in a physical booth. You can not participate again." already_voted_in_web: "You have already participated in this poll. If you vote again it will be overwritten." diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 70a18a2ac..458156352 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -487,6 +487,7 @@ es: description: Regístrate para poder votar propuestas ciudadanas y las cuestiones que pregunta a sus vecinos el Ayuntamiento. Toma decisiones municipales de forma directa. help_text_1: "Las votaciones se convocan cuando una propuesta ciudadana alcanza el 1% de apoyos del censo con derecho a voto. En las votaciones también se pueden incluir cuestiones que el Ayuntamiento somete a decisión directa de la ciudadanía." help_text_2: "Para participar en la próxima votación tienes que registrarte en %{org} y verificar tu cuenta. Pueden votar todas las personas empadronadas en la ciudad mayores de 16 años. Los resultados de todas las votaciones serán vinculantes para el gobierno." + no_polls: "No hay votaciones abiertas." show: already_voted_in_booth: "Ya has participado en esta votación en urnas presenciales, no puedes volver a participar." already_voted_in_web: "Ya has participado en esta votación. Si vuelves a votar se sobreescribirá tu resultado anterior." diff --git a/spec/features/polls/polls_spec.rb b/spec/features/polls/polls_spec.rb index c2e8413cf..be6e6ff4e 100644 --- a/spec/features/polls/polls_spec.rb +++ b/spec/features/polls/polls_spec.rb @@ -9,6 +9,9 @@ feature 'Polls' do context '#index' do scenario 'Polls can be listed' do + visit polls_path + expect(page).to have_content('There are no open votings') + polls = create_list(:poll, 3) create(:image, imageable: polls[0]) create(:image, imageable: polls[1])