Defect #32183 » 32183_notified_events_other_issue_attributes.patch
| app/models/journal.rb | ||
|---|---|---|
|
end
|
||
|
def send_notification
|
||
|
if notify? && (Setting.notified_events.include?('issue_updated') ||
|
||
|
return unless notify?
|
||
|
if Setting.notified_events.include?('issue_updated') ||
|
||
|
(Setting.notified_events.include?('issue_note_added') && notes.present?) ||
|
||
|
(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_other_attributes_updated') && (
|
||
|
(
|
||
|
journalized.journalized_attribute_names - ['status_id', 'assigned_to_id', 'priority_id', 'fixed_version_id']
|
||
|
).any?{|attr_name| detail_for_attribute(attr_name).present?} ||
|
||
|
(['attachment', 'relation', 'cf'] & details.collect(&:property)).any?
|
||
|
))
|
||
|
Mailer.deliver_issue_edit(self)
|
||
|
end
|
||
|
end
|
||
| config/locales/en.yml | ||
|---|---|---|
|
label_issue_assigned_to_updated: Assignee updated
|
||
|
label_issue_priority_updated: Priority updated
|
||
|
label_issue_fixed_version_updated: Target version updated
|
||
|
label_issue_other_attributes_updated: Other issue attributes updated
|
||
|
label_document: Document
|
||
|
label_document_new: New document
|
||
|
label_document_plural: Documents
|
||
| lib/redmine/notifiable.rb | ||
|---|---|---|
|
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_other_attributes_updated', 'issue_updated')
|
||
|
notifications << Notifiable.new('news_added')
|
||
|
notifications << Notifiable.new('news_comment_added')
|
||
|
notifications << Notifiable.new('document_added')
|
||
| test/unit/journal_observer_test.rb | ||
|---|---|---|
|
fixtures :issues, :issue_statuses, :journals, :journal_details, :projects,
|
||
|
:projects_trackers, :trackers, :enabled_modules, :enumerations,
|
||
|
:users, :user_preferences, :email_addresses, :roles, :members, :member_roles,
|
||
|
:versions
|
||
|
:versions,
|
||
|
:custom_fields, :custom_fields_trackers, :custom_values
|
||
|
def setup
|
||
|
User.current = nil
|
||
| ... | ... | |
|
assert_equal 0, ActionMailer::Base.deliveries.size
|
||
|
end
|
||
|
end
|
||
|
def test_create_should_send_email_notification_with_issue_other_attributes_updated
|
||
|
with_settings :notified_events => %w(issue_other_attributes_updated) do
|
||
|
user = User.find_by_login('jsmith')
|
||
|
# subject
|
||
|
ActionMailer::Base.deliveries.clear
|
||
|
issue = issues(:issues_001)
|
||
|
issue.init_journal(user)
|
||
|
issue.subject = 'Update subject'
|
||
|
assert issue.save
|
||
|
assert_equal 2, ActionMailer::Base.deliveries.size
|
||
|
# custom field
|
||
|
ActionMailer::Base.deliveries.clear
|
||
|
issue = issues(:issues_003)
|
||
|
issue.init_journal(user)
|
||
|
issue.custom_field_values = {'2' => 'Update custom field'}
|
||
|
assert issue.save
|
||
|
assert_equal 2, ActionMailer::Base.deliveries.size
|
||
|
end
|
||
|
end
|
||
|
def test_create_should_not_send_email_notification_without_issue_other_attributes_updated
|
||
|
with_settings :notified_events => [] do
|
||
|
user = User.find_by_login('jsmith')
|
||
|
# subject
|
||
|
ActionMailer::Base.deliveries.clear
|
||
|
issue = issues(:issues_001)
|
||
|
issue.init_journal(user)
|
||
|
issue.subject = 'Update subject'
|
||
|
assert issue.save
|
||
|
assert_equal 0, ActionMailer::Base.deliveries.size
|
||
|
# custom field
|
||
|
ActionMailer::Base.deliveries.clear
|
||
|
issue = issues(:issues_003)
|
||
|
issue.init_journal(user)
|
||
|
issue.custom_field_values = {'2' => 'Update custom field'}
|
||
|
assert issue.save
|
||
|
assert_equal 0, ActionMailer::Base.deliveries.size
|
||
|
end
|
||
|
end
|
||
|
end
|
||
- « Previous
- 1
- 2
- 3
- 4
- Next »