+ <%= link_to t("admin.stats.show.direct_messages"),
+ direct_messages_admin_stats_path, class: "button hollow" %>
+ <%= link_to t("admin.stats.show.proposal_notifications"),
+ proposal_notifications_admin_stats_path, class: "button hollow" %>
+
+
diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml
index ec3542c2c..2f73f64d8 100755
--- a/config/locales/admin.en.yml
+++ b/config/locales/admin.en.yml
@@ -288,6 +288,16 @@ 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
+ total: Total
+ 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 eef5ce10e..5aada1ce1 100644
--- a/config/locales/admin.es.yml
+++ b/config/locales/admin.es.yml
@@ -286,6 +286,16 @@ es:
votes: Votos
spending_proposals_title: Propuestas de inversión
visits_title: Visitas
+ direct_messages: Mensajes directos
+ proposal_notifications: Notificaciones de propuestas
+ direct_messages:
+ title: Mensajes directos
+ total: Total
+ users_who_have_sent_message: Usuarios que han enviado un mensaje privado
+ proposal_notifications:
+ title: Notificaciones de propuestas
+ total: Total
+ proposals_with_notifications: Propuestas con notificaciones
tags:
create: Crear Tema
destroy: Eliminar Tema
diff --git a/config/routes.rb b/config/routes.rb
index d805683d3..ed2ee34e4 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -182,7 +182,10 @@ Rails.application.routes.draw do
end
resource :activity, controller: :activity, only: :show
- resource :stats, only: :show
+ resource :stats, only: :show do
+ get :proposal_notifications, on: :collection
+ get :direct_messages, on: :collection
+ end
namespace :api do
resource :stats, only: :show
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