(Setting.notified_events.include?('issue_status_updated') && new_status.present?) ||
(Setting.notified_events.include?('issue_assigned_to_updated') && detail_for_attribute('assigned_to_id').present?) ||
(Setting.notified_events.include?('issue_priority_updated') && new_value_for('priority_id').present?) ||
- (Setting.notified_events.include?('issue_fixed_version_updated') && detail_for_attribute('fixed_version_id').present?)
+ (Setting.notified_events.include?('issue_fixed_version_updated') && detail_for_attribute('fixed_version_id').present?) ||
+ (Setting.notified_events.include?('issue_attachment_added') && details.any? {|d| d.property == 'attachment' && d.value })
)
Mailer.deliver_issue_edit(self)
end
label_issue_assigned_to_updated: Assignee updated
label_issue_priority_updated: Priority updated
label_issue_fixed_version_updated: Target version updated
+ label_issue_attachment_added: Attachment added
label_document: Document
label_document_new: New document
label_document_plural: Documents
notifications << Notifiable.new('issue_assigned_to_updated', 'issue_updated')
notifications << Notifiable.new('issue_priority_updated', 'issue_updated')
notifications << Notifiable.new('issue_fixed_version_updated', 'issue_updated')
+ notifications << Notifiable.new('issue_attachment_added', 'issue_updated')
notifications << Notifiable.new('news_added')
notifications << Notifiable.new('news_comment_added')
notifications << Notifiable.new('document_added')
fixtures :issues, :issue_statuses, :journals, :journal_details, :projects,
:projects_trackers, :trackers, :enabled_modules, :enumerations,
:users, :user_preferences, :email_addresses, :roles, :members, :member_roles,
- :versions, :issue_categories
+ :versions, :issue_categories, :attachments
def setup
User.current = nil
assert_equal 0, ActionMailer::Base.deliveries.size
end
end
+
+ def test_create_should_send_email_notification_with_issue_attachment_added
+ set_tmp_attachments_directory
+ with_settings :notified_events => %w(issue_attachment_added) do
+ user = User.find_by_login('jsmith')
+ issue = issues(:issues_001)
+ issue.init_journal(user)
+ issue.save_attachments(
+ { 'p0' => {'file' => mock_file_with_options(:original_filename => 'upload')} }
+ )
+
+ assert issue.save
+ assert_equal 2, ActionMailer::Base.deliveries.size
+ end
+ end
+
+ def test_create_should_not_send_email_notification_without_issue_attachment_added
+ set_tmp_attachments_directory
+ with_settings :notified_events => [] do
+ user = User.find_by_login('jsmith')
+ issue = issues(:issues_001)
+ issue.init_journal(user)
+ issue.save_attachments(
+ { 'p0' => {'file' => mock_file_with_options(:original_filename => 'upload')} }
+ )
+
+ assert issue.save
+ assert_equal 0, ActionMailer::Base.deliveries.size
+ end
+ end
end