@@ -231,6 +231,28 module IssuesHelper | |||||
231 | out |
|
231 | out | |
232 | end |
|
232 | end | |
233 |
|
233 | |||
|
234 | def email_issue_attributes(issue, user) | |||
|
235 | items = [] | |||
|
236 | %w(author status priority assigned_to category fixed_version).each do |attribute| | |||
|
237 | unless issue.disabled_core_fields.include?(attribute+"_id") | |||
|
238 | items << "#{l("field_#{attribute}")}: #{issue.send attribute}" | |||
|
239 | end | |||
|
240 | end | |||
|
241 | issue.visible_custom_field_values(user).each do |value| | |||
|
242 | items << "#{value.custom_field.name}: #{show_value(value)}" | |||
|
243 | end | |||
|
244 | items | |||
|
245 | end | |||
|
246 | ||||
|
247 | def render_email_issue_attributes(issue, user, html=false) | |||
|
248 | items = email_issue_attributes(issue, user) | |||
|
249 | if html | |||
|
250 | content_tag('ul', items.map{|s| content_tag('li', s)}.join("\n").html_safe) | |||
|
251 | else | |||
|
252 | items.map{|s| "* #{s}"}.join("\n") | |||
|
253 | end | |||
|
254 | end | |||
|
255 | ||||
234 | # Returns the textual representation of a journal details |
|
256 | # Returns the textual representation of a journal details | |
235 | # as an array of strings |
|
257 | # as an array of strings | |
236 | def details_to_strings(details, no_html=false, options={}) |
|
258 | def details_to_strings(details, no_html=false, options={}) |
@@ -1,16 +1,6 | |||||
1 | <h1><%= link_to(h("#{issue.tracker.name} ##{issue.id}: #{issue.subject}"), issue_url) %></h1> |
|
1 | <h1><%= link_to(h("#{issue.tracker.name} ##{issue.id}: #{issue.subject}"), issue_url) %></h1> | |
2 |
|
2 | |||
3 | <ul> |
|
3 | <%= render_email_issue_attributes(issue, users.first, true) %> | |
4 | <li><%=l(:field_author)%>: <%=h issue.author %></li> |
|
|||
5 | <li><%=l(:field_status)%>: <%=h issue.status %></li> |
|
|||
6 | <li><%=l(:field_priority)%>: <%=h issue.priority %></li> |
|
|||
7 | <li><%=l(:field_assigned_to)%>: <%=h issue.assigned_to %></li> |
|
|||
8 | <li><%=l(:field_category)%>: <%=h issue.category %></li> |
|
|||
9 | <li><%=l(:field_fixed_version)%>: <%=h issue.fixed_version %></li> |
|
|||
10 | <% issue.visible_custom_field_values(users.first).each do |c| %> |
|
|||
11 | <li><%=h c.custom_field.name %>: <%=h show_value(c) %></li> |
|
|||
12 | <% end %> |
|
|||
13 | </ul> |
|
|||
14 |
|
4 | |||
15 | <%= textilizable(issue, :description, :only_path => false) %> |
|
5 | <%= textilizable(issue, :description, :only_path => false) %> | |
16 |
|
6 |
@@ -1,14 +1,7 | |||||
1 | <%= "#{issue.tracker.name} ##{issue.id}: #{issue.subject}" %> |
|
1 | <%= "#{issue.tracker.name} ##{issue.id}: #{issue.subject}" %> | |
2 | <%= issue_url %> |
|
2 | <%= issue_url %> | |
3 |
|
3 | |||
4 | * <%=l(:field_author)%>: <%= issue.author %> |
|
4 | <%= render_email_issue_attributes(issue, users.first) %> | |
5 | * <%=l(:field_status)%>: <%= issue.status %> |
|
|||
6 | * <%=l(:field_priority)%>: <%= issue.priority %> |
|
|||
7 | * <%=l(:field_assigned_to)%>: <%= issue.assigned_to %> |
|
|||
8 | * <%=l(:field_category)%>: <%= issue.category %> |
|
|||
9 | * <%=l(:field_fixed_version)%>: <%= issue.fixed_version %> |
|
|||
10 | <% issue.visible_custom_field_values(users.first).each do |c| %>* <%= c.custom_field.name %>: <%= show_value(c) %> |
|
|||
11 | <% end -%> |
|
|||
12 | ---------------------------------------- |
|
5 | ---------------------------------------- | |
13 | <%= issue.description %> |
|
6 | <%= issue.description %> | |
14 |
|
7 |
@@ -317,6 +317,29 class MailerTest < ActiveSupport::TestCase | |||||
317 | assert !last_email.bcc.include?(user.mail) |
|
317 | assert !last_email.bcc.include?(user.mail) | |
318 | end |
|
318 | end | |
319 |
|
319 | |||
|
320 | def test_issue_add_should_include_enabled_fields | |||
|
321 | Setting.default_language = 'en' | |||
|
322 | issue = Issue.find(2) | |||
|
323 | assert Mailer.deliver_issue_add(issue) | |||
|
324 | assert_mail_body_match '* Target version: 1.0', last_email | |||
|
325 | assert_select_email do | |||
|
326 | assert_select 'li', :text => 'Target version: 1.0' | |||
|
327 | end | |||
|
328 | end | |||
|
329 | ||||
|
330 | def test_issue_add_should_not_include_disabled_fields | |||
|
331 | Setting.default_language = 'en' | |||
|
332 | issue = Issue.find(2) | |||
|
333 | tracker = issue.tracker | |||
|
334 | tracker.core_fields -= ['fixed_version_id'] | |||
|
335 | tracker.save! | |||
|
336 | assert Mailer.deliver_issue_add(issue) | |||
|
337 | assert_mail_body_no_match 'Target version', last_email | |||
|
338 | assert_select_email do | |||
|
339 | assert_select 'li', :text => /Target version/, :count => 0 | |||
|
340 | end | |||
|
341 | end | |||
|
342 | ||||
320 | # test mailer methods for each language |
|
343 | # test mailer methods for each language | |
321 | def test_issue_add |
|
344 | def test_issue_add | |
322 | issue = Issue.find(1) |
|
345 | issue = Issue.find(1) |
General Comments 0
You need to be logged in to leave comments.
Login now