]> source.dussan.org Git - redmine.git/commitdiff
Add a link to the issues list in a reminder email (#33099).
authorGo MAEDA <maeda@farend.jp>
Sat, 7 Mar 2020 08:20:26 +0000 (08:20 +0000)
committerGo MAEDA <maeda@farend.jp>
Sat, 7 Mar 2020 08:20:26 +0000 (08:20 +0000)
Patch by Go MAEDA.

git-svn-id: http://svn.redmine.org/redmine/trunk@19565 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/mailer.rb
app/views/mailer/reminder.html.erb
app/views/mailer/reminder.text.erb
test/unit/mailer_test.rb

index 01ef16e60932c3b4f0e59efe37e35dfbde7c2c49..590199ed81bab37724602be3702157bd17ac4642 100644 (file)
@@ -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' => '<t+'},
+      :v =>{'assigned_to_id' => ['me'], 'due_date' => [days]})
+
     query = IssueQuery.new(:name => '_')
     query.add_filter('assigned_to_id', '=', ['me'])
     @open_issues_count = query.issue_count
index 6f86fcbf8d8df2b439dfc3d335021489a7f6f862..9ffb6cce82e303cb938fc75d731a8fd40403f444 100644 (file)
@@ -1,4 +1,4 @@
-<p><%= l(:mail_body_reminder, :count => @issues.size, :days => @days) %></p>
+<p><%= l(:mail_body_reminder, :count => link_to(@issues.size, @reminder_issues_url), :days => @days).html_safe %></p>
 
 <ul>
 <% @issues.each do |issue| -%>
@@ -6,4 +6,4 @@
 <% end -%>
 </ul>
 
-<p><%= link_to l(:label_issue_view_all), @issues_url %> (<%= l(:label_x_open_issues_abbr, :count => @open_issues_count) %>)</p>
+<p><%= link_to l(:label_issue_view_all), @open_issues_url %> (<%= l(:label_x_open_issues_abbr, :count => @open_issues_count) %>)</p>
index 5d38d1ac35ad11b7a1fa643581b5d230ff1c2241..7cf18059005842f6ca74cdffdb9024bd045407c8 100644 (file)
@@ -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 %>
index 31fe956c70526da3651b1f719c926c2a610dd88b..3f6e974cae28e720f4cd1a8e2fd89c558278e1c4 100644 (file)
@@ -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