Replaced Issue with work package in settings for email notifications

pull/849/head
Jonas Heinrich 11 years ago
parent 5edbfcea4b
commit ff93647e52
  1. 4
      app/models/journal_observer.rb
  2. 3
      config/locales/de.yml
  3. 5
      config/locales/en.yml
  4. 21
      db/migrate/20140127134733_fix_issue_in_notifications.rb
  5. 4
      lib/redmine/notifiable.rb
  6. 8
      test/unit/journal_observer_test.rb
  7. 2
      test/unit/lib/redmine/notifiable_test.rb

@ -39,9 +39,9 @@ class JournalObserver < ActiveRecord::Observer
def after_create_issue_journal(journal)
if Setting.notified_events.include?('work_package_updated') ||
(Setting.notified_events.include?('issue_note_added') && journal.notes.present?) ||
(Setting.notified_events.include?('work_package_note_added') && journal.notes.present?) ||
(Setting.notified_events.include?('status_updated') && journal.changed_data.has_key?(:status_id)) ||
(Setting.notified_events.include?('issue_priority_updated') && journal.changed_data.has_key?(:priority_id))
(Setting.notified_events.include?('work_package_priority_updated') && journal.changed_data.has_key?(:priority_id))
issue = journal.journable
recipients = issue.recipients + issue.watcher_recipients
users = User.find_all_by_mails(recipients.uniq)

@ -742,7 +742,9 @@ de:
label_work_package_category_plural: "Arbeitspaket-Kategorien"
label_work_package_hierarchy: "Arbeitspaket-Hierarchie"
label_work_package_new: "Neues Arbeitspaket"
label_work_package_note_added: "Kommentar zu Arbeitspaket hinzugefügt"
label_work_package_plural: "Arbeitspakete"
label_work_package_priority_updated: "Arbeitspaketpriorität aktualisiert"
label_work_package_status_new: "Neuer Status"
label_work_package_status_plural: "Arbeitspaket-Status"
label_work_package_tracking: "Arbeitspakete"
@ -909,6 +911,7 @@ de:
label_start_to_start: "Anfang bis Anfang"
label_statistics: "Statistiken"
label_status: "Status"
label_status_updated: "Arbeitspaketstatus aktualisiert"
label_stay_logged_in: "Angemeldet bleiben"
label_string: "Text"
label_subproject_new: "Neues Unterprojekt"

@ -739,7 +739,9 @@ en:
label_work_package_category_plural: "Work package categories"
label_work_package_hierarchy: "Work package hierarchy"
label_work_package_new: "New work package"
label_work_package_note_added: "Work package note added"
label_work_package_plural: "Work packages"
label_work_package_priority_updated: "Work package priority updated"
label_work_package_status_new: "New status"
label_work_package_status_plural: "Work package statuses"
label_work_package_tracking: "Work package tracking"
@ -906,6 +908,7 @@ en:
label_start_to_start: "start to start"
label_statistics: "Statistics"
label_status: "Status"
label_status_updated: "Work package status updated"
label_stay_logged_in: "Stay logged in"
label_string: "Text"
label_subproject_new: "New subproject"
@ -1305,7 +1308,7 @@ en:
text_enumeration_destroy_question: "%{count} objects are assigned to this value."
text_file_repository_writable: "Attachments directory writable"
text_git_repo_example: "a bare and local repository (e.g. /gitrepo, c:\\gitrepo)"
text_work_package_added: "Work package %{id} has been reported by %{author}."
text_git_repo_example: "Work package %{id} has been reported by %{author}."
text_work_package_category_destroy_assignments: "Remove category assignments"
text_work_package_category_destroy_question: "Some work packages (%{count}) are assigned to this category. What do you want to do?"
text_work_package_category_reassign_to: "Reassign work packages to this category"

@ -10,13 +10,26 @@
#++
class FixIssueInNotifications < ActiveRecord::Migration
REPLACED = {
"issue_added" => "work_package_added",
"issue_updated" => "work_package_updated",
"issue_priority_updated" => "work_package_priority_updated",
}
def up
Setting['notified_events']= Setting['notified_events'].map {|m| m.gsub("issue_added","work_package_added")}
Setting['notified_events']= Setting['notified_events'].map {|m| m.gsub("issue_updated","work_package_updated")}
Setting['notified_events']= replace(Setting['notified_events'], REPLACED)
end
def down
Setting['notified_events']= Setting['notified_events'].map {|m| m.gsub("work_package_added","issue_added")}
Setting['notified_events']= Setting['notified_events'].map {|m| m.gsub("work_package_updated","issue_updated")}
Setting['notified_events']= replace(Setting['notified_events'], REPLACED.invert)
end
private
def replace(value,mapping)
if value.respond_to? :map
value.map { |s| mapping[s].nil? ? s : mapping[s] }
else
mapping[value].nil? ? value : mapping[value]
end
end
end

@ -39,9 +39,9 @@ module Redmine
notifications = []
notifications << Notifiable.new('work_package_added')
notifications << Notifiable.new('work_package_updated')
notifications << Notifiable.new('issue_note_added', 'work_package_updated')
notifications << Notifiable.new('work_package_note_added', 'work_package_updated')
notifications << Notifiable.new('status_updated', 'work_package_updated')
notifications << Notifiable.new('issue_priority_updated', 'work_package_updated')
notifications << Notifiable.new('work_package_priority_updated', 'work_package_updated')
notifications << Notifiable.new('news_added')
notifications << Notifiable.new('news_comment_added')
notifications << Notifiable.new('file_added')

@ -71,11 +71,11 @@ class JournalObserverTest < ActiveSupport::TestCase
end
end
context "#after_create for 'issue_note_added'" do
context "#after_create for 'work_package_note_added'" do
should "should send a notification when configured as a notification" do
@issue.recreate_initial_journal!
Setting.notified_events = ['issue_note_added']
Setting.notified_events = ['work_package_note_added']
assert_difference('ActionMailer::Base.deliveries.size', +1) do
@issue.add_journal(@user, 'This update has a note')
assert @issue.save
@ -111,9 +111,9 @@ class JournalObserverTest < ActiveSupport::TestCase
end
end
context "#after_create for 'issue_priority_updated'" do
context "#after_create for 'work_package_priority_updated'" do
should "should send a notification when configured as a notification" do
Setting.notified_events = ['issue_priority_updated']
Setting.notified_events = ['work_package_priority_updated']
assert_difference('ActionMailer::Base.deliveries.size', +1) do
@issue.add_journal(@user)
@issue.priority = IssuePriority.generate!

@ -35,7 +35,7 @@ class Redmine::NotifiableTest < ActiveSupport::TestCase
def test_all
assert_equal 11, Redmine::Notifiable.all.length
%w(work_package_added work_package_updated issue_note_added status_updated issue_priority_updated news_added news_comment_added file_added message_posted wiki_content_added wiki_content_updated).each do |notifiable|
%w(work_package_added work_package_updated work_package_note_added status_updated work_package_priority_updated news_added news_comment_added file_added message_posted wiki_content_added wiki_content_updated).each do |notifiable|
assert Redmine::Notifiable.all.collect(&:name).include?(notifiable), "missing #{notifiable}"
end
end

Loading…
Cancel
Save