Project

General

Profile

Feature #29771 » 29771-v2.patch

slightly updated the test code - Go MAEDA, 2018-11-04 02:26

View differences:

app/models/mailer.rb
584 584
    issues_by_assignee.each do |assignee, issues|
585 585
      if assignee.is_a?(User) && assignee.active? && issues.present?
586 586
        visible_issues = issues.select {|i| i.visible?(assignee)}
587
        visible_issues.sort!{|a, b| (b.due_date <=> a.due_date).nonzero? || (a.id <=> b.id)}
587 588
        reminder(assignee, visible_issues, days).deliver_later if visible_issues.present?
588 589
      end
589 590
    end
test/unit/mailer_test.rb
621 621
    end
622 622
  end
623 623

  
624
  def test_reminders_should_sort_issues_by_due_date
625
    user = User.find(2)
626
    Issue.generate!(:assigned_to => user, :due_date => 5.days.from_now, :subject => 'baz')
627
    Issue.generate!(:assigned_to => user, :due_date => 5.days.from_now, :subject => 'qux')
628
    Issue.generate!(:assigned_to => user, :due_date => 6.days.from_now, :subject => 'foo')
629
    Issue.generate!(:assigned_to => user, :due_date => 6.days.from_now, :subject => 'bar')
630
    ActionMailer::Base.deliveries.clear
631

  
632
    Mailer.reminders(:days => 7, :users => [user.id])
633
    assert_equal 1, ActionMailer::Base.deliveries.size
634
    assert_select_email do
635
      assert_select 'li', 4
636
      assert_select 'li:nth-child(1)', /foo/
637
      assert_select 'li:nth-child(2)', /bar/
638
      assert_select 'li:nth-child(3)', /baz/
639
      assert_select 'li:nth-child(4)', /qux/
640
    end
641
  end
642

  
624 643
  def test_security_notification
625 644
    set_language_if_valid User.find(1).language
626 645
    with_settings :emails_footer => "footer without link" do
(2-2/3)