end
strings << show_detail(detail, no_html, options)
end
- values_by_field.each do |field, changes|
- detail = JournalDetail.new(:property => 'cf', :prop_key => field.id.to_s)
- detail.instance_variable_set "@custom_field", field
- if changes[:added].any?
- detail.value = changes[:added]
- strings << show_detail(detail, no_html, options)
- elsif changes[:deleted].any?
- detail.old_value = changes[:deleted]
- strings << show_detail(detail, no_html, options)
+ if values_by_field.present?
+ multiple_values_detail = Struct.new(:property, :prop_key, :custom_field, :old_value, :value)
+ values_by_field.each do |field, changes|
+ if changes[:added].any?
+ detail = multiple_values_detail.new('cf', field.id.to_s, field)
+ detail.value = changes[:added]
+ strings << show_detail(detail, no_html, options)
+ end
+ if changes[:deleted].any?
+ detail = multiple_values_detail.new('cf', field.id.to_s, field)
+ detail.old_value = changes[:deleted]
+ strings << show_detail(detail, no_html, options)
+ end
end
end
strings
assert_equal "<strong>Precedes</strong> deleted (<i>Issue ##{issue.id}</i>)", show_detail(detail, false)
end
+ def test_details_to_strings_with_multiple_values_removed_from_custom_field
+ field = IssueCustomField.generate!(:name => 'User', :field_format => 'user', :multiple => true)
+ details = []
+ details << JournalDetail.new(:property => 'cf', :prop_key => field.id.to_s, :old_value => '1', :value => nil)
+ details << JournalDetail.new(:property => 'cf', :prop_key => field.id.to_s, :old_value => '3', :value => nil)
+
+ assert_equal ["User deleted (Dave Lopper, Redmine Admin)"], details_to_strings(details, true)
+ assert_equal ["<strong>User</strong> deleted (<del><i>Dave Lopper, Redmine Admin</i></del>)"], details_to_strings(details, false)
+ end
+
+ def test_details_to_strings_with_multiple_values_added_to_custom_field
+ field = IssueCustomField.generate!(:name => 'User', :field_format => 'user', :multiple => true)
+ details = []
+ details << JournalDetail.new(:property => 'cf', :prop_key => field.id.to_s, :old_value => nil, :value => '1')
+ details << JournalDetail.new(:property => 'cf', :prop_key => field.id.to_s, :old_value => nil, :value => '3')
+
+ assert_equal ["User Dave Lopper, Redmine Admin added"], details_to_strings(details, true)
+ assert_equal ["<strong>User</strong> <i>Dave Lopper, Redmine Admin</i> added"], details_to_strings(details, false)
+ end
+
+ def test_details_to_strings_with_multiple_values_added_and_removed_from_custom_field
+ field = IssueCustomField.generate!(:name => 'User', :field_format => 'user', :multiple => true)
+ details = []
+ details << JournalDetail.new(:property => 'cf', :prop_key => field.id.to_s, :old_value => nil, :value => '1')
+ details << JournalDetail.new(:property => 'cf', :prop_key => field.id.to_s, :old_value => '2', :value => nil)
+ details << JournalDetail.new(:property => 'cf', :prop_key => field.id.to_s, :old_value => '3', :value => nil)
+
+ assert_equal [
+ "User Redmine Admin added",
+ "User deleted (Dave Lopper, John Smith)"
+ ], details_to_strings(details, true)
+ assert_equal [
+ "<strong>User</strong> <i>Redmine Admin</i> added",
+ "<strong>User</strong> deleted (<del><i>Dave Lopper, John Smith</i></del>)"
+ ], details_to_strings(details, false)
+ end
+
def test_find_name_by_reflection_should_return_nil_for_missing_record
assert_nil find_name_by_reflection('status', 99)
end