31104-show-number-of-open-issues-v2.patch

Yuichi HARADA, 2019-04-11 02:34

Download (3.81 KB)

View differences:

app/models/mailer.rb
553 553
    @issues_url = url_for(:controller => 'issues', :action => 'index',
554 554
                                :set_filter => 1, :assigned_to_id => 'me',
555 555
                                :sort => 'due_date:asc')
556
    query = IssueQuery.new(:name => '_')
557
    query.add_filter('assigned_to_id', '=', ['me'])
558
    @open_issues_count = query.issue_count
556 559
    mail :to => user,
557 560
      :subject => l(:mail_subject_reminder, :count => issues.size, :days => days)
558 561
  end
......
770 773
    @references_objects << object
771 774
  end
772 775
end
773

  
app/views/mailer/reminder.html.erb
6 6
<% end -%>
7 7
</ul>
8 8

  
9
<p><%= link_to l(:label_issue_view_all), @issues_url %></p>
9
<p><%= link_to l(:label_issue_view_all), @issues_url %> (<%= l(:label_x_open_issues_abbr, :count => @open_issues_count) %>)</p>
app/views/mailer/reminder.text.erb
4 4
* <%= "#{issue.project} - #{issue.tracker} ##{issue.id}: #{issue.subject}" %>
5 5
<% end -%>
6 6

  
7
<%= l(:label_issue_view_all)%> (<%= l(:label_x_open_issues_abbr, :count => @open_issues_count) %>)
7 8
<%= @issues_url %>
test/unit/mailer_test.rb
621 621
    mail = last_email
622 622
    assert mail.bcc.include?('dlopper@somenet.foo')
623 623
    assert_mail_body_match 'Bug #3: Error 281 when updating a recipe', mail
624
    assert_mail_body_match 'View all issues (2 open)', mail
624 625
    assert_select_email do
625 626
      assert_select 'a[href=?]',
626 627
                    'http://localhost:3000/issues?assigned_to_id=me&set_filter=1&sort=due_date%3Aasc',
627 628
                    :text => 'View all issues'
629
      assert_select '/p:nth-last-of-type(1)', :text => 'View all issues (2 open)'
628 630
    end
629 631
    assert_equal '1 issue(s) due in the next 42 days', mail.subject
630 632
  end
......
671 673
  def test_reminder_should_include_issues_assigned_to_groups
672 674
    with_settings :default_language => 'en', :issue_group_assignment => '1' do
673 675
      group = Group.generate!
676
      user_dlopper = User.find(3)
674 677
      Member.create!(:project_id => 1, :principal => group, :role_ids => [1])
675 678
      group.users << User.find(2)
676
      group.users << User.find(3)
679
      group.users << user_dlopper
677 680

  
681
      Issue.update_all(:assigned_to_id => nil)
682
      due_date = 10.days.from_now
683
      Issue.update(1, :due_date => due_date, :assigned_to_id => user_dlopper.id)
684
      Issue.update(2, :due_date => due_date, :assigned_to_id => group.id)
678 685
      Issue.create!(:project_id => 1, :tracker_id => 1, :status_id => 1,
679 686
                      :subject => 'Assigned to group', :assigned_to => group,
680 687
                      :due_date => 5.days.from_now,
......
685 692
      assert_equal 2, ActionMailer::Base.deliveries.size
686 693
      assert_equal %w(dlopper@somenet.foo jsmith@somenet.foo), recipients
687 694
      ActionMailer::Base.deliveries.each do |mail|
695
        assert_mail_body_match '1 issue(s) that are assigned to you are due in the next 7 days::', mail
688 696
        assert_mail_body_match 'Assigned to group', mail
697
        assert_mail_body_match "View all issues (#{mail.bcc.include?('dlopper@somenet.foo') ? 3 : 2} open)", mail
689 698
      end
690 699
    end
691 700
  end