Project

General

Profile

Feature #33099 » reminder-add-link.patch

Go MAEDA, 2020-03-05 10:11

View differences:

app/models/mailer.rb
553 553
  def reminder(user, issues, days)
554 554
    @issues = issues
555 555
    @days = days
556
    @issues_url = url_for(:controller => 'issues', :action => 'index',
556
    @open_issues_url = url_for(:controller => 'issues', :action => 'index',
557 557
                                :set_filter => 1, :assigned_to_id => 'me',
558 558
                                :sort => 'due_date:asc')
559
    @reminder_issues_url = url_for(:controller => 'issues', :action => 'index',
560
      :set_filter => 1, :sort => 'due_date:asc',
561
      :f => ['status_id', 'assigned_to_id', "due_date"],
562
      :op => {'status_id' => 'o', 'assigned_to_id' => '=', 'due_date' => '<t+'},
563
      :v =>{'assigned_to_id' => ['me'], 'due_date' => [days]})
564

  
559 565
    query = IssueQuery.new(:name => '_')
560 566
    query.add_filter('assigned_to_id', '=', ['me'])
561 567
    @open_issues_count = query.issue_count
app/views/mailer/reminder.html.erb
1
<p><%= l(:mail_body_reminder, :count => @issues.size, :days => @days) %></p>
1
<p><%= l(:mail_body_reminder, :count => link_to(@issues.size, @reminder_issues_url), :days => @days).html_safe %></p>
2 2

  
3 3
<ul>
4 4
<% @issues.each do |issue| -%>
......
6 6
<% end -%>
7 7
</ul>
8 8

  
9
<p><%= link_to l(:label_issue_view_all), @issues_url %> (<%= l(:label_x_open_issues_abbr, :count => @open_issues_count) %>)</p>
9
<p><%= link_to l(:label_issue_view_all), @open_issues_url %> (<%= l(:label_x_open_issues_abbr, :count => @open_issues_count) %>)</p>
app/views/mailer/reminder.text.erb
5 5
<% end -%>
6 6

  
7 7
<%= l(:label_issue_view_all)%> (<%= l(:label_x_open_issues_abbr, :count => @open_issues_count) %>)
8
<%= @issues_url %>
8
<%= @open_issues_url %>
test/unit/mailer_test.rb
676 676

  
677 677
  def test_reminders
678 678
    users(:users_003).pref.update_attribute :time_zone, 'UTC' # dlopper
679
    Mailer.reminders(:days => 42)
679
    days = 42
680
    Mailer.reminders(:days => days)
680 681
    assert_equal 1, ActionMailer::Base.deliveries.size
681 682
    mail = last_email
682 683
    assert mail.bcc.include?('dlopper@somenet.foo')
683 684
    assert_mail_body_match 'Bug #3: Error 281 when updating a recipe (5 days late)', mail
684 685
    assert_mail_body_match 'View all issues (2 open)', mail
685 686
    assert_select_email do
687
      assert_select 'a[href=?]',
688
                    "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}",
689
                    :text => '1'
686 690
      assert_select 'a[href=?]',
687 691
                    'http://localhost:3000/issues?assigned_to_id=me&set_filter=1&sort=due_date%3Aasc',
688 692
                    :text => 'View all issues'
689 693
      assert_select '/p:nth-last-of-type(1)', :text => 'View all issues (2 open)'
690 694
    end
691
    assert_equal '1 issue(s) due in the next 42 days', mail.subject
695
    assert_equal "1 issue(s) due in the next #{days} days", mail.subject
692 696
  end
693 697

  
694 698
  def test_reminders_language_auto
(3-3/3)