diff --git a/app/views/admin/stats/direct_messages.html.erb b/app/views/admin/stats/direct_messages.html.erb
index 33c6ff517..17532f00f 100644
--- a/app/views/admin/stats/direct_messages.html.erb
+++ b/app/views/admin/stats/direct_messages.html.erb
@@ -10,14 +10,18 @@
<%= t("admin.stats.direct_messages.total") %>
- <%= @direct_messages.count %>
+
+ <%= @direct_messages.count %>
+
<%= t("admin.stats.direct_messages.users_who_have_sent_message") %>
- <%= @users_who_have_sent_message.count %>
+
+ <%= @users_who_have_sent_message.count %>
+
diff --git a/app/views/admin/stats/proposal_notifications.html.erb b/app/views/admin/stats/proposal_notifications.html.erb
index 106be14cf..10f620ff6 100644
--- a/app/views/admin/stats/proposal_notifications.html.erb
+++ b/app/views/admin/stats/proposal_notifications.html.erb
@@ -10,14 +10,18 @@
<%= t("admin.stats.proposal_notifications.total") %>
- <%= @proposal_notifications.count %>
+
+ <%= @proposal_notifications.count %>
+
<%= t("admin.stats.proposal_notifications.proposals_with_notifications") %>
- <%= @proposals_with_notifications.count %>
+
+ <%= @proposals_with_notifications.count %>
+
@@ -28,8 +32,10 @@
<% @proposal_notifications.each do |notification| %>
-
<%= link_to notification.proposal.title, proposal_path(notification.proposal) %>
-
<%= notification.title %>
-
<%= notification.body %>
+
+
<%= link_to notification.proposal.title, proposal_path(notification.proposal) %>
+
<%= notification.title %>
+
<%= notification.body %>
+
<% end %>
diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml
index ec3542c2c..088fd1078 100755
--- a/config/locales/admin.en.yml
+++ b/config/locales/admin.en.yml
@@ -288,6 +288,15 @@ en:
votes: Total votes
spending_proposals_title: Spending Proposals
visits_title: Visits
+ direct_messages: Direct messages
+ proposal_notifications: Proposal notifications
+ direct_messages:
+ title: Direct messages
+ users_who_have_sent_message: Users that have sent a private message
+ proposal_notifications:
+ title: Proposal notifications
+ total: Total
+ proposals_with_notifications: Proposals with notifications
tags:
create: Create Topic
destroy: Destroy Topic
diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml
index 62778a194..b0b83f6ac 100644
--- a/config/locales/admin.es.yml
+++ b/config/locales/admin.es.yml
@@ -292,7 +292,7 @@ es:
title: Mensajes directos
users_who_have_sent_message: Usuarios que han enviado un mensaje privado
proposal_notifications:
- title: Mensajes directos
+ title: Notificaciones de propuestas
total: Total
proposals_with_notifications: Propuestas con notificaciones
tags:
diff --git a/spec/factories.rb b/spec/factories.rb
index 4ead8ecac..209f45b28 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -327,8 +327,8 @@ FactoryGirl.define do
end
factory :proposal_notification do
- title "Thank you for supporting my proposal"
- body "Please let others know so we can make it happen"
+ sequence(:title) { |n| "Thank you for supporting my proposal #{n}" }
+ sequence(:body) { |n| "Please let others know so we can make it happen #{n}" }
proposal
end
diff --git a/spec/features/admin/stats_spec.rb b/spec/features/admin/stats_spec.rb
index 461f7ef32..7f343d1bc 100644
--- a/spec/features/admin/stats_spec.rb
+++ b/spec/features/admin/stats_spec.rb
@@ -70,4 +70,64 @@ feature 'Stats' do
expect(page).to have_content "Level 2 User (1)"
end
+ context "Proposal notifications" do
+
+ scenario "Summary stats" do
+ proposal = create(:proposal)
+
+ create(:proposal_notification, proposal: proposal)
+ create(:proposal_notification, proposal: proposal)
+ create(:proposal_notification)
+
+ visit admin_stats_path
+ click_link "Proposal notifications"
+
+ within("#proposal_notifications_count") do
+ expect(page).to have_content "3"
+ end
+
+ within("#proposals_with_notifications_count") do
+ expect(page).to have_content "2"
+ end
+ end
+
+ scenario "Index" do
+ 3.times { create(:proposal_notification) }
+
+ visit admin_stats_path
+ click_link "Proposal notifications"
+
+ expect(page).to have_css(".proposal_notification", count: 3)
+
+ ProposalNotification.all.each do |proposal_notification|
+ expect(page).to have_content proposal_notification.title
+ expect(page).to have_content proposal_notification.body
+ end
+ end
+
+ end
+
+ context "Direct messages" do
+
+ scenario "Summary stats" do
+ sender = create(:user, :level_two)
+
+ create(:direct_message, sender: sender)
+ create(:direct_message, sender: sender)
+ create(:direct_message)
+
+ visit admin_stats_path
+ click_link "Direct messages"
+
+ within("#direct_messages_count") do
+ expect(page).to have_content "3"
+ end
+
+ within("#users_who_have_sent_message_count") do
+ expect(page).to have_content "2"
+ end
+ end
+
+ end
+
end