From 8b492d6dc8c17647285ec3641bc0ec7a9e9a8739 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Tue, 17 Oct 2017 01:28:07 -0400 Subject: [PATCH 1/4] made the mistake of not checking all cases --- .../map_activity_mailer/daily_summary.html.erb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/map_activity_mailer/daily_summary.html.erb b/app/views/map_activity_mailer/daily_summary.html.erb index 99fd53f7..827e0e99 100644 --- a/app/views/map_activity_mailer/daily_summary.html.erb +++ b/app/views/map_activity_mailer/daily_summary.html.erb @@ -15,22 +15,22 @@ <%= link_to @map.name, map_url(@map) %>

- <% if @summary_data[:stats][:messages_sent] > 0 %> + <% if !@summary_data[:stats][:messages_sent].nil? %>

<%= pluralize(@summary_data[:stats][:messages_sent], 'message') %>

<% end %> - <% if @summary_data[:stats][:topics_added] > 0 %> + <% if !@summary_data[:stats][:topics_added].nil? %>

<%= pluralize(@summary_data[:stats][:topics_added], 'topic') %> added

<% end %> - <% if @summary_data[:stats][:synapses_added] > 0 %> + <% if !@summary_data[:stats][:synapses_added].nil? %>

<%= pluralize(@summary_data[:stats][:synapses_added], 'synapse') %> added

<% end %> - <% if @summary_data[:stats][:topics_moved] > 0 %> + <% if !@summary_data[:stats][:topics_moved].nil? %>

<%= pluralize(@summary_data[:stats][:topics_moved], 'topic') %> moved

<% end %> - <% if @summary_data[:stats][:topics_removed] > 0 %> + <% if !@summary_data[:stats][:topics_removed].nil? %>

<%= pluralize(@summary_data[:stats][:topics_removed], 'topic') %> removed

<% end %> - <% if @summary_data[:stats][:synapses_removed] > 0 %> + <% if !@summary_data[:stats][:synapses_removed].nil? %>

<%= pluralize(@summary_data[:stats][:synapses_removed], 'synapse') %> removed

<% end %>
@@ -61,7 +61,7 @@ <% end %> - + <% if @summary_data[:topics_removed] || @summary_data[:synapses_removed] %>
<% if @summary_data[:topics_removed] %> From cbf44e3dfef83364293dab45d6adff80a217f904 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Tue, 17 Oct 2017 08:28:00 -0700 Subject: [PATCH 2/4] add one view test --- .../daily_summary.html.erb_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 spec/views/map_activity_mailer/daily_summary.html.erb_spec.rb diff --git a/spec/views/map_activity_mailer/daily_summary.html.erb_spec.rb b/spec/views/map_activity_mailer/daily_summary.html.erb_spec.rb new file mode 100644 index 00000000..f581a1d2 --- /dev/null +++ b/spec/views/map_activity_mailer/daily_summary.html.erb_spec.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe 'map_activity_mailer/daily_summary.html.erb' do + it 'displays messages sent' do + assign(:user, create(:user)) + assign(:map, create(:map)) + assign(:summary_data, stats: { + messages_sent: 5 + }) + + render + + expect(rendered).to match(/5 messages/) + end +end From 901eb4a513766c6504c5a3626e7384e834fb4095 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Tue, 17 Oct 2017 12:06:37 -0400 Subject: [PATCH 3/4] Update daily_summary.html.erb --- app/views/map_activity_mailer/daily_summary.html.erb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/map_activity_mailer/daily_summary.html.erb b/app/views/map_activity_mailer/daily_summary.html.erb index 827e0e99..d28d00a5 100644 --- a/app/views/map_activity_mailer/daily_summary.html.erb +++ b/app/views/map_activity_mailer/daily_summary.html.erb @@ -15,22 +15,22 @@ <%= link_to @map.name, map_url(@map) %>

- <% if !@summary_data[:stats][:messages_sent].nil? %> + <% if @summary_data[:stats][:messages_sent] %>

<%= pluralize(@summary_data[:stats][:messages_sent], 'message') %>

<% end %> - <% if !@summary_data[:stats][:topics_added].nil? %> + <% if @summary_data[:stats][:topics_added] %>

<%= pluralize(@summary_data[:stats][:topics_added], 'topic') %> added

<% end %> - <% if !@summary_data[:stats][:synapses_added].nil? %> + <% if @summary_data[:stats][:synapses_added] %>

<%= pluralize(@summary_data[:stats][:synapses_added], 'synapse') %> added

<% end %> - <% if !@summary_data[:stats][:topics_moved].nil? %> + <% if @summary_data[:stats][:topics_moved] %>

<%= pluralize(@summary_data[:stats][:topics_moved], 'topic') %> moved

<% end %> - <% if !@summary_data[:stats][:topics_removed].nil? %> + <% if @summary_data[:stats][:topics_removed] %>

<%= pluralize(@summary_data[:stats][:topics_removed], 'topic') %> removed

<% end %> - <% if !@summary_data[:stats][:synapses_removed].nil? %> + <% if @summary_data[:stats][:synapses_removed] %>

<%= pluralize(@summary_data[:stats][:synapses_removed], 'synapse') %> removed

<% end %>
From e66498a861615423bcee08b09e85929ae6e98543 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Tue, 17 Oct 2017 12:16:03 -0400 Subject: [PATCH 4/4] add logging for delayedJob --- config/initializers/delayed_job.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/config/initializers/delayed_job.rb b/config/initializers/delayed_job.rb index d3132394..c4725b19 100644 --- a/config/initializers/delayed_job.rb +++ b/config/initializers/delayed_job.rb @@ -1,9 +1,14 @@ -Delayed::Worker.class_eval do - - def handle_failed_job_with_notification(job, error) - handle_failed_job_without_notification(job, error) - ExceptionNotifier.notify_exception(error) - end - alias_method_chain :handle_failed_job, :notification +# frozen_string_literal: true +module ExceptionNotifierInDelayedJob + def handle_failed_job(job, error) + super + ExceptionNotfier.notify_exception(error) + end end + +Delayed::Worker.class_eval do + prepend ExceptionNotifierInDelayedJob +end + +Delayed::Worker.logger = Logger.new(File.join(Rails.root, 'log', 'delayed_job.log'))