From a8ed1c7c5f8a2a3811c23564cf7378b15609f62b Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Sat, 7 Mar 2020 08:20:26 +0000 Subject: [PATCH] Add a link to the issues list in a reminder email (#33099). Patch by Go MAEDA. git-svn-id: http://svn.redmine.org/redmine/trunk@19565 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/mailer.rb | 8 +++++++- app/views/mailer/reminder.html.erb | 4 ++-- app/views/mailer/reminder.text.erb | 2 +- test/unit/mailer_test.rb | 8 ++++++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 01ef16e60..590199ed8 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -553,9 +553,15 @@ class Mailer < ActionMailer::Base def reminder(user, issues, days) @issues = issues @days = days - @issues_url = url_for(:controller => 'issues', :action => 'index', + @open_issues_url = url_for(:controller => 'issues', :action => 'index', :set_filter => 1, :assigned_to_id => 'me', :sort => 'due_date:asc') + @reminder_issues_url = url_for(:controller => 'issues', :action => 'index', + :set_filter => 1, :sort => 'due_date:asc', + :f => ['status_id', 'assigned_to_id', "due_date"], + :op => {'status_id' => 'o', 'assigned_to_id' => '=', 'due_date' => '{'assigned_to_id' => ['me'], 'due_date' => [days]}) + query = IssueQuery.new(:name => '_') query.add_filter('assigned_to_id', '=', ['me']) @open_issues_count = query.issue_count diff --git a/app/views/mailer/reminder.html.erb b/app/views/mailer/reminder.html.erb index 6f86fcbf8..9ffb6cce8 100644 --- a/app/views/mailer/reminder.html.erb +++ b/app/views/mailer/reminder.html.erb @@ -1,4 +1,4 @@ -

<%= l(:mail_body_reminder, :count => @issues.size, :days => @days) %>

+

<%= l(:mail_body_reminder, :count => link_to(@issues.size, @reminder_issues_url), :days => @days).html_safe %>

-

<%= link_to l(:label_issue_view_all), @issues_url %> (<%= l(:label_x_open_issues_abbr, :count => @open_issues_count) %>)

+

<%= link_to l(:label_issue_view_all), @open_issues_url %> (<%= l(:label_x_open_issues_abbr, :count => @open_issues_count) %>)

diff --git a/app/views/mailer/reminder.text.erb b/app/views/mailer/reminder.text.erb index 5d38d1ac3..7cf180590 100644 --- a/app/views/mailer/reminder.text.erb +++ b/app/views/mailer/reminder.text.erb @@ -5,4 +5,4 @@ <% end -%> <%= l(:label_issue_view_all)%> (<%= l(:label_x_open_issues_abbr, :count => @open_issues_count) %>) -<%= @issues_url %> +<%= @open_issues_url %> diff --git a/test/unit/mailer_test.rb b/test/unit/mailer_test.rb index 31fe956c7..3f6e974ca 100644 --- a/test/unit/mailer_test.rb +++ b/test/unit/mailer_test.rb @@ -676,19 +676,23 @@ class MailerTest < ActiveSupport::TestCase def test_reminders users(:users_003).pref.update_attribute :time_zone, 'UTC' # dlopper - Mailer.reminders(:days => 42) + days = 42 + Mailer.reminders(:days => days) assert_equal 1, ActionMailer::Base.deliveries.size mail = last_email assert mail.bcc.include?('dlopper@somenet.foo') assert_mail_body_match 'Bug #3: Error 281 when updating a recipe (5 days late)', mail assert_mail_body_match 'View all issues (2 open)', mail assert_select_email do + assert_select 'a[href=?]', + "http://localhost:3000/issues?f%5B%5D=status_id&f%5B%5D=assigned_to_id&f%5B%5D=due_date&op%5Bassigned_to_id%5D=%3D&op%5Bdue_date%5D=%3Ct%2B&op%5Bstatus_id%5D=o&set_filter=1&sort=due_date%3Aasc&v%5Bassigned_to_id%5D%5B%5D=me&v%5Bdue_date%5D%5B%5D=#{days}", + :text => '1' assert_select 'a[href=?]', 'http://localhost:3000/issues?assigned_to_id=me&set_filter=1&sort=due_date%3Aasc', :text => 'View all issues' assert_select '/p:nth-last-of-type(1)', :text => 'View all issues (2 open)' end - assert_equal '1 issue(s) due in the next 42 days', mail.subject + assert_equal "1 issue(s) due in the next #{days} days", mail.subject end def test_reminders_language_auto -- 2.39.5