Commit 4d65532158fb826b51290e0bbc30f34a1ec21d49
1 parent
8da05a4f
Exists in
master
and in
4 other branches
Issue_status_changed email added
Showing
3 changed files
with
47 additions
and
0 deletions
Show diff stats
app/mailers/notify.rb
@@ -83,6 +83,14 @@ class Notify < ActionMailer::Base | @@ -83,6 +83,14 @@ class Notify < ActionMailer::Base | ||
83 | subject: subject("access to project was granted")) | 83 | subject: subject("access to project was granted")) |
84 | end | 84 | end |
85 | 85 | ||
86 | + def issue_status_changed_email(recipient_id, issue_id, status, updated_by_user_id) | ||
87 | + @issue = Issue.find issue_id | ||
88 | + @issue_status = status | ||
89 | + @updated_by = User.find updated_by_user_id | ||
90 | + mail(to: recipient(recipient_id), | ||
91 | + subject: subject("changed issue ##{@issue.id}", @issue.title)) | ||
92 | + end | ||
93 | + | ||
86 | private | 94 | private |
87 | 95 | ||
88 | # Look up a User by their ID and return their email address | 96 | # Look up a User by their ID and return their email address |
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +%td.content{align: "left", style: "font-family: Helvetica, Arial, sans-serif; padding: 20px 0 0;", valign: "top", width: "600"} | ||
2 | + %table{border: "0", cellpadding: "0", cellspacing: "0", style: "color: #717171; font: normal 11px Helvetica, Arial, sans-serif; margin: 0; padding: 0;", width: "600"} | ||
3 | + %tr | ||
4 | + %td{style: "font-size: 1px; line-height: 1px;", width: "21"} | ||
5 | + %td{align: "left", style: "padding: 20px 0 0;"} | ||
6 | + %h2{style: "color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "} | ||
7 | + = "Issue was #{@issue_status} by #{@updated_by.name}" | ||
8 | + %td{style: "font-size: 1px; line-height: 1px;", width: "21"} | ||
9 | + %tr | ||
10 | + %td{style: "font-size: 1px; line-height: 1px;", width: "21"} | ||
11 | + %td{align: "left", style: "padding: 20px 0 0;"} | ||
12 | + %h2{style: "color:#646464 !important; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "} | ||
13 | + = "Issue ##{@issue.id}" | ||
14 | + = link_to_gfm truncate(@issue.title, length: 45), project_issue_url(@issue.project, @issue), title: @issue.title | ||
15 | + %br | ||
16 | + |
spec/mailers/notify_spec.rb
@@ -91,6 +91,29 @@ describe Notify do | @@ -91,6 +91,29 @@ describe Notify do | ||
91 | should have_body_text /#{project_issue_path project, issue}/ | 91 | should have_body_text /#{project_issue_path project, issue}/ |
92 | end | 92 | end |
93 | end | 93 | end |
94 | + | ||
95 | + describe 'status changed' do | ||
96 | + let(:current_user) { Factory.create :user, email: "current@email.com" } | ||
97 | + let(:status) { 'closed' } | ||
98 | + subject { Notify.issue_status_changed_email(recipient.id, issue.id, status, current_user) } | ||
99 | + | ||
100 | + it 'has the correct subject' do | ||
101 | + should have_subject /changed issue ##{issue.id} \| #{issue.title}/i | ||
102 | + end | ||
103 | + | ||
104 | + it 'contains the new status' do | ||
105 | + should have_body_text /#{status}/i | ||
106 | + end | ||
107 | + | ||
108 | + it 'contains the user name' do | ||
109 | + should have_body_text /#{current_user.name}/i | ||
110 | + end | ||
111 | + | ||
112 | + it 'contains a link to the issue' do | ||
113 | + should have_body_text /#{project_issue_path project, issue}/ | ||
114 | + end | ||
115 | + end | ||
116 | + | ||
94 | end | 117 | end |
95 | 118 | ||
96 | context 'for merge requests' do | 119 | context 'for merge requests' do |