##// END OF EJS Templates
Fixed that standard fields disabled still appear in email notifications (#14584)....
Jean-Philippe Lang -
r11849:fd1b06070559
parent child
Show More
@@ -231,6 +231,28 module IssuesHelper
231 231 out
232 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 256 # Returns the textual representation of a journal details
235 257 # as an array of strings
236 258 def details_to_strings(details, no_html=false, options={})
@@ -1,16 +1,6
1 1 <h1><%= link_to(h("#{issue.tracker.name} ##{issue.id}: #{issue.subject}"), issue_url) %></h1>
2 2
3 <ul>
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>
3 <%= render_email_issue_attributes(issue, users.first, true) %>
14 4
15 5 <%= textilizable(issue, :description, :only_path => false) %>
16 6
@@ -1,14 +1,7
1 1 <%= "#{issue.tracker.name} ##{issue.id}: #{issue.subject}" %>
2 2 <%= issue_url %>
3 3
4 * <%=l(:field_author)%>: <%= issue.author %>
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 -%>
4 <%= render_email_issue_attributes(issue, users.first) %>
12 5 ----------------------------------------
13 6 <%= issue.description %>
14 7
@@ -317,6 +317,29 class MailerTest < ActiveSupport::TestCase
317 317 assert !last_email.bcc.include?(user.mail)
318 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 343 # test mailer methods for each language
321 344 def test_issue_add
322 345 issue = Issue.find(1)
General Comments 0
You need to be logged in to leave comments. Login now