Class: ProjectNotification

Inherits:
ViewMailer
  • Object
show all
Includes:
ActionView::Helpers::DateHelper, TestRunHelper
Defined in:
app/mailers/project_notification.rb

Instance Method Summary collapse

Methods included from TestRunHelper

#test_run_fail_summary, #test_run_summary, #test_status

Methods inherited from ViewMailer

#current_ability

Instance Method Details

#ci_configuration_error(test_run, message, options = {}) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
103
# File 'app/mailers/project_notification.rb', line 92

def ci_configuration_error(test_run, message, options={})
  @test_run = test_run
  @project = test_run.project
  @message = message
  @additional_info = options[:additional_info]

  mail({
    to:       options.fetch(:to, @project.maintainers),
    subject:  "configuration error",
    template: "ci_configuration_error"
  })
end

#follow_up(antecedent) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'app/mailers/project_notification.rb', line 106

def follow_up(antecedent)
  @antecedent = antecedent
  @ticket = antecedent.ticket
  @project = @ticket.project
  @reporter = antecedent.reporter
  @customer = @antecedent.customer

  mail({
    to: @reporter,
    subject: "Sample Ticket follow-up",
    template: "follow_up"
  })
end

#maintainer_of_deploy(maintainer, deploy) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'app/mailers/project_notification.rb', line 68

def maintainer_of_deploy(maintainer, deploy)
  @project = deploy.project
  @release = deploy.build_release
  @maintainer = maintainer

  if @maintainer.respond_to?(:reset_authentication_token!)
    @maintainer.reset_authentication_token!
    @auth_token = @maintainer.authentication_token
  end

  if @release.commits.empty? && @release.can_read_commits?
    @release.load_commits!
    @release.load_tickets!
    @release.build_changes_from_commits
  end

  mail({
    to:       @maintainer,
    subject:  "deploy to #{deploy.environment_name} complete. Click to Release!",
    template: "new_release"
  })
end

#release(release, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/mailers/project_notification.rb', line 6

def release(release, options={})
  @release = release
  @project = release.project

  mail({
    from:     release.user,
    to:       options.fetch(:to, @release.notification_recipients),
    cc:       options.fetch(:cc, @project.maintainers),
    subject:  "new release to #{release.environment_name}",
    template: "new_release"
  })
end

#test_results(test_run, options = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/mailers/project_notification.rb', line 20

def test_results(test_run, options={})
  @test_run = test_run
  @project = test_run.project

  committers = test_run.commits_since_last_test_run.map { |commit| commit.author_email.downcase }
  recipients = (committers + Array(test_run.agent_email)).uniq \
             - @project.maintainers.map(&:email) \
             + @project.maintainers

  mail({
    to:       recipients,
    subject:  test_run_summary(test_run),
    template: "test_run"
  })
end

#testing_note(testing_note, recipients) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/mailers/project_notification.rb', line 37

def testing_note(testing_note, recipients)
  @note = testing_note
  @tester = testing_note.user
  @ticket = testing_note.ticket
  @project = testing_note.project
  @verdict = testing_note.verdict

  case @verdict
  when "fails"
    @verb = "failed"
    @noun = "Failing Verdict"
  when "none"
    @verb = "commented on"
    @noun = "Comment"
  when "works"
    @verb = "passed"
    @noun = "Passing Verdict"
  else
    Rails.logger.warn "[project_notification] Unhandled TestingNote verdict: #{@verdict.inspect}"
    return
  end

  mail({
    from:     @tester,
    to:       recipients - [@tester],
    subject:  "#{@tester.name} #{@verb} ticket ##{@ticket.number}",
    template: "testing_note"
  })
end