Project

General

Profile

Feature #36691 » fix_failing_tests.diff

Jens Krämer, 2022-04-06 08:18

View differences:

test/unit/jobs/destroy_project_job_test.rb
25 25
  setup do
26 26
    @project = Project.find 1
27 27
    @user = User.find_by_admin true
28
    ActionMailer::Base.deliveries.clear
28 29
  end
29 30

  
30 31
  test "schedule should mark project and children for deletion" do
......
52 53
    assert_difference 'Project.count', -5 do
53 54
      DestroyProjectJob.perform_now @project.id, @user.id, '127.0.0.1'
54 55
    end
55
    assert_enqueued_with(
56
      job: ActionMailer::MailDeliveryJob,
57
      args: ->(job_args){
58
        job_args[1] == 'security_notification' &&
59
        job_args[3].to_s.include?("mail_destroy_project_with_subprojects_successful")
60
      }
61
    )
56
    if m = ActionMailer::Base.deliveries.last
57
      assert_match /Security notification/, m.subject
58
      assert_match /deleted successfully/, m.text_part.to_s
59
    else
60
      assert_enqueued_with(
61
        job: ActionMailer::MailDeliveryJob,
62
        args: ->(job_args){
63
          job_args[1] == 'security_notification' &&
64
          job_args[3].to_s.include?("mail_destroy_project_with_subprojects_successful")
65
        }
66
      )
67
    end
62 68
  end
63 69
end
test/unit/jobs/destroy_projects_job_test.rb
25 25
  setup do
26 26
    @projects = Project.where(id: [1, 2]).to_a
27 27
    @user = User.find_by_admin true
28
    ActionMailer::Base.deliveries.clear
28 29
  end
29 30

  
30 31
  test "schedule should mark projects and children for deletion" do
......
52 53
    assert_difference 'Project.count', -6 do
53 54
      DestroyProjectsJob.perform_now @projects.map(&:id), @user.id, '127.0.0.1'
54 55
    end
55
    assert_enqueued_with(
56
      job: ActionMailer::MailDeliveryJob,
57
      args: ->(job_args){
58
        job_args[1] == 'security_notification' &&
59
        job_args[3].to_s.include?("mail_destroy_project_with_subprojects_successful")
60
      }
61
    )
56
    if m = ActionMailer::Base.deliveries.last
57
      assert_match /Security notification/, m.subject
58
      assert_match /deleted successfully/, m.text_part.to_s
59
    else
60
      fail 'foo'
61
      assert_enqueued_with(
62
        job: ActionMailer::MailDeliveryJob,
63
        args: ->(job_args){
64
          job_args[1] == 'security_notification' &&
65
          job_args[3].to_s.include?("mail_destroy_project_with_subprojects_successful")
66
        }
67
      )
68
    end
62 69
  end
63 70
end
(2-2/2)