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 5db9d0755..386f52193 100644
--- a/config/locales/en/admin.yml
+++ b/config/locales/en/admin.yml
@@ -1304,6 +1304,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 f43cefd02..35e611a92 100644
--- a/config/locales/es/admin.yml
+++ b/config/locales/es/admin.yml
@@ -1303,6 +1303,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