From e3eb87addb1389aaccd29ee359c3a2dcfbc7afde Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 28 Jul 2016 16:00:13 +0200 Subject: [PATCH] checks for deleted proposals --- .../admin/stats/proposal_notifications.html.erb | 8 +++++++- config/locales/en/admin.yml | 1 + config/locales/es/admin.yml | 1 + spec/features/admin/stats_spec.rb | 14 ++++++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/views/admin/stats/proposal_notifications.html.erb b/app/views/admin/stats/proposal_notifications.html.erb index 102eb0c60..e26ac3431 100644 --- a/app/views/admin/stats/proposal_notifications.html.erb +++ b/app/views/admin/stats/proposal_notifications.html.erb @@ -31,7 +31,13 @@

<%= notification.title %> - <%= link_to notification.proposal.title, proposal_path(notification.proposal) %> + + <% if notification.proposal.present? %> + <%= link_to notification.proposal.title, proposal_path(notification.proposal) %> + <% else %> + <%= t("admin.stats.proposal_notifications.not_available") %>
+ <% end %> +

<%= notification.body %>

diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index edff8acf7..596d6f43c 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -1302,6 +1302,7 @@ en: title: Proposal notifications total: Total proposals_with_notifications: Proposals with notifications + not_available: "Proposal not available" polls: title: Poll Stats all: Polls diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index c099bce58..62807d187 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -1301,6 +1301,7 @@ es: title: Notificaciones de propuestas total: Total proposals_with_notifications: Propuestas con notificaciones + not_available: "Esta propuesta ya no está disponible" polls: title: Estadísticas de votaciones all: Votaciones diff --git a/spec/features/admin/stats_spec.rb b/spec/features/admin/stats_spec.rb index 48e2513ba..24df9b3bc 100644 --- a/spec/features/admin/stats_spec.rb +++ b/spec/features/admin/stats_spec.rb @@ -137,6 +137,20 @@ feature 'Stats' do end end + scenario "Deleted proposals" do + proposal_notification = create(:proposal_notification) + proposal_notification.proposal.destroy + + visit admin_stats_path + click_link "Proposal notifications" + + expect(page).to have_css(".proposal_notification", count: 1) + + expect(page).to have_content proposal_notification.title + expect(page).to have_content proposal_notification.body + expect(page).to have_content "Proposal not available" + end + end context "Direct messages" do