From 9c9dc6e8147a3e0bf3239511c094dc5f9d2a59a0 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 17 May 2009 09:55:13 +0000 Subject: [PATCH] Adds email notification on wiki changes (#413). It's disabled by default and can be enabled in application settings. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2749 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/settings_controller.rb | 2 +- app/models/mailer.rb | 34 ++++++++++++++++++- app/models/wiki_content.rb | 6 +++- app/models/wiki_content_observer.rb | 28 +++++++++++++++ .../mailer/wiki_content_added.text.html.rhtml | 3 ++ .../wiki_content_added.text.plain.rhtml | 5 +++ .../wiki_content_updated.text.html.rhtml | 6 ++++ .../wiki_content_updated.text.plain.rhtml | 8 +++++ config/environment.rb | 2 +- config/locales/bg.yml | 6 ++++ config/locales/bs.yml | 6 ++++ config/locales/ca.yml | 6 ++++ config/locales/cs.yml | 6 ++++ config/locales/da.yml | 6 ++++ config/locales/de.yml | 6 ++++ config/locales/en.yml | 6 ++++ config/locales/es.yml | 6 ++++ config/locales/fi.yml | 6 ++++ config/locales/fr.yml | 6 ++++ config/locales/gl.yml | 6 ++++ config/locales/he.yml | 6 ++++ config/locales/hu.yml | 6 ++++ config/locales/it.yml | 6 ++++ config/locales/ja.yml | 6 ++++ config/locales/ko.yml | 6 ++++ config/locales/lt.yml | 6 ++++ config/locales/nl.yml | 6 ++++ config/locales/no.yml | 6 ++++ config/locales/pl.yml | 6 ++++ config/locales/pt-BR.yml | 6 ++++ config/locales/pt.yml | 6 ++++ config/locales/ro.yml | 6 ++++ config/locales/ru.yml | 6 ++++ config/locales/sk.yml | 6 ++++ config/locales/sl.yml | 6 ++++ config/locales/sr.yml | 6 ++++ config/locales/sv.yml | 6 ++++ config/locales/th.yml | 6 ++++ config/locales/tr.yml | 6 ++++ config/locales/uk.yml | 6 ++++ config/locales/vi.yml | 6 ++++ config/locales/zh-TW.yml | 6 ++++ config/locales/zh.yml | 6 ++++ test/unit/wiki_content_test.rb | 20 +++++++++++ 44 files changed, 314 insertions(+), 4 deletions(-) create mode 100644 app/models/wiki_content_observer.rb create mode 100644 app/views/mailer/wiki_content_added.text.html.rhtml create mode 100644 app/views/mailer/wiki_content_added.text.plain.rhtml create mode 100644 app/views/mailer/wiki_content_updated.text.html.rhtml create mode 100644 app/views/mailer/wiki_content_updated.text.plain.rhtml diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index 7d99a7266..c1d94850f 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -24,7 +24,7 @@ class SettingsController < ApplicationController end def edit - @notifiables = %w(issue_added issue_updated news_added document_added file_added message_posted) + @notifiables = %w(issue_added issue_updated news_added document_added file_added message_posted wiki_content_added wiki_content_updated) if request.post? && params[:settings] && params[:settings].is_a?(Hash) settings = (params[:settings] || {}).dup.symbolize_keys settings.each do |name, value| diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 992fd50c0..993d85da6 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -152,6 +152,37 @@ class Mailer < ActionMailer::Base body :message => message, :message_url => url_for(:controller => 'messages', :action => 'show', :board_id => message.board_id, :id => message.root) end + + # Builds a tmail object used to email the recipients of a project of the specified wiki content was updated. + # + # Example: + # wiki_content_updated(wiki_content) => tmail object + # Mailer.deliver_wiki_content_updated(wiki_content) => sends an email to the project's recipients + def wiki_content_added(wiki_content) + redmine_headers 'Project' => wiki_content.project.identifier, + 'Wiki-Page-Id' => wiki_content.page.id + message_id wiki_content + recipients wiki_content.project.recipients + subject "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :page => wiki_content.page.pretty_title)}" + body :wiki_content => wiki_content, + :wiki_content_url => url_for(:controller => 'wiki', :action => 'index', :id => wiki_content.project, :page => wiki_content.page.title) + end + + # Builds a tmail object used to email the recipients of a project of the specified wiki content was updated. + # + # Example: + # wiki_content_updated(wiki_content) => tmail object + # Mailer.deliver_wiki_content_updated(wiki_content) => sends an email to the project's recipients + def wiki_content_updated(wiki_content) + redmine_headers 'Project' => wiki_content.project.identifier, + 'Wiki-Page-Id' => wiki_content.page.id + message_id wiki_content + recipients wiki_content.project.recipients + subject "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_updated, :page => wiki_content.page.pretty_title)}" + body :wiki_content => wiki_content, + :wiki_content_url => url_for(:controller => 'wiki', :action => 'index', :id => wiki_content.project, :page => wiki_content.page.title), + :wiki_diff_url => url_for(:controller => 'wiki', :action => 'diff', :id => wiki_content.project, :page => wiki_content.page.title, :version => wiki_content.version) + end # Builds a tmail object used to email the specified user their account information. # @@ -325,7 +356,8 @@ class Mailer < ActionMailer::Base def self.message_id_for(object) # id + timestamp should reduce the odds of a collision # as far as we don't send multiple emails for the same object - hash = "redmine.#{object.class.name.demodulize.underscore}-#{object.id}.#{object.created_on.strftime("%Y%m%d%H%M%S")}" + timestamp = object.send(object.respond_to?(:created_on) ? :created_on : :updated_on) + hash = "redmine.#{object.class.name.demodulize.underscore}-#{object.id}.#{timestamp.strftime("%Y%m%d%H%M%S")}" host = Setting.mail_from.to_s.gsub(%r{^.*@}, '') host = "#{::Socket.gethostname}.redmine" if host.empty? "<#{hash}@#{host}>" diff --git a/app/models/wiki_content.rb b/app/models/wiki_content.rb index d206be97d..372ca8365 100644 --- a/app/models/wiki_content.rb +++ b/app/models/wiki_content.rb @@ -25,6 +25,11 @@ class WikiContent < ActiveRecord::Base validates_length_of :comments, :maximum => 255, :allow_nil => true acts_as_versioned + + def project + page.project + end + class Version belongs_to :page, :class_name => '::WikiPage', :foreign_key => 'page_id' belongs_to :author, :class_name => '::User', :foreign_key => 'author_id' @@ -87,5 +92,4 @@ class WikiContent < ActiveRecord::Base :conditions => ["wiki_content_id = ? AND version < ?", wiki_content_id, version]) end end - end diff --git a/app/models/wiki_content_observer.rb b/app/models/wiki_content_observer.rb new file mode 100644 index 000000000..d9dbe5708 --- /dev/null +++ b/app/models/wiki_content_observer.rb @@ -0,0 +1,28 @@ +# Redmine - project management software +# Copyright (C) 2006-2009 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class WikiContentObserver < ActiveRecord::Observer + def after_create(wiki_content) + Mailer.deliver_wiki_content_added(wiki_content) if Setting.notified_events.include?('wiki_content_added') + end + + def after_update(wiki_content) + if wiki_content.text_changed? + Mailer.deliver_wiki_content_updated(wiki_content) if Setting.notified_events.include?('wiki_content_updated') + end + end +end diff --git a/app/views/mailer/wiki_content_added.text.html.rhtml b/app/views/mailer/wiki_content_added.text.html.rhtml new file mode 100644 index 000000000..92e368f54 --- /dev/null +++ b/app/views/mailer/wiki_content_added.text.html.rhtml @@ -0,0 +1,3 @@ +

<%= l(:mail_body_wiki_content_added, :page => link_to(h(@wiki_content.page.pretty_title), @wiki_content_url), + :author => h(@wiki_content.author)) %>
+<%=h @wiki_content.comments %>

diff --git a/app/views/mailer/wiki_content_added.text.plain.rhtml b/app/views/mailer/wiki_content_added.text.plain.rhtml new file mode 100644 index 000000000..5699eecd5 --- /dev/null +++ b/app/views/mailer/wiki_content_added.text.plain.rhtml @@ -0,0 +1,5 @@ +<%= l(:mail_body_wiki_content_added, :page => h(@wiki_content.page.pretty_title), + :author => h(@wiki_content.author)) %> +<%= @wiki_content.comments %> + +<%= @wiki_content_url %> diff --git a/app/views/mailer/wiki_content_updated.text.html.rhtml b/app/views/mailer/wiki_content_updated.text.html.rhtml new file mode 100644 index 000000000..9f0bf0c87 --- /dev/null +++ b/app/views/mailer/wiki_content_updated.text.html.rhtml @@ -0,0 +1,6 @@ +

<%= l(:mail_body_wiki_content_updated, :page => link_to(h(@wiki_content.page.pretty_title), @wiki_content_url), + :author => h(@wiki_content.author)) %>
+<%=h @wiki_content.comments %>

+ +

<%= l(:label_view_diff) %>:
+<%= link_to @wiki_diff_url, @wiki_diff_url %>

diff --git a/app/views/mailer/wiki_content_updated.text.plain.rhtml b/app/views/mailer/wiki_content_updated.text.plain.rhtml new file mode 100644 index 000000000..29767a65b --- /dev/null +++ b/app/views/mailer/wiki_content_updated.text.plain.rhtml @@ -0,0 +1,8 @@ +<%= l(:mail_body_wiki_content_updated, :page => h(@wiki_content.page.pretty_title), + :author => h(@wiki_content.author)) %> +<%= @wiki_content.comments %> + +<%= @wiki_content.page.pretty_title %>: +<%= @wiki_content_url %> +<%= l(:label_view_diff) %>: +<%= @wiki_diff_url %> diff --git a/config/environment.rb b/config/environment.rb index 826856d13..f98968bcb 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -36,7 +36,7 @@ Rails::Initializer.run do |config| # Activate observers that should always be running # config.active_record.observers = :cacher, :garbage_collector - config.active_record.observers = :message_observer, :issue_observer, :journal_observer, :news_observer, :document_observer + config.active_record.observers = :message_observer, :issue_observer, :journal_observer, :news_observer, :document_observer, :wiki_content_observer # Make Active Record use UTC-base instead of local time # config.active_record.default_timezone = :utc diff --git a/config/locales/bg.yml b/config/locales/bg.yml index 47fb305c4..36923c83c 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -790,3 +790,9 @@ bg: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/bs.yml b/config/locales/bs.yml index fe0c30c28..59b252143 100644 --- a/config/locales/bs.yml +++ b/config/locales/bs.yml @@ -823,3 +823,9 @@ bs: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/ca.yml b/config/locales/ca.yml index b8c84975c..20113f971 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -793,3 +793,9 @@ ca: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/cs.yml b/config/locales/cs.yml index 077cd1ba1..a8040ca1e 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -796,3 +796,9 @@ cs: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/da.yml b/config/locales/da.yml index fb47fb798..6ce2fecb4 100644 --- a/config/locales/da.yml +++ b/config/locales/da.yml @@ -823,3 +823,9 @@ da: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/de.yml b/config/locales/de.yml index 278586afc..26855bfdb 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -822,3 +822,9 @@ de: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/en.yml b/config/locales/en.yml index cdc505a53..3cfcbc66e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -149,6 +149,10 @@ en: mail_body_account_activation_request: "A new user ({{value}}) has registered. The account is pending your approval:" mail_subject_reminder: "{{count}} issue(s) due in the next days" mail_body_reminder: "{{count}} issue(s) that are assigned to you are due in the next {{days}} days:" + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: "The '{{page}}' wiki page has been added by {{author}}." + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + mail_body_wiki_content_updated: "The '{{page}}' wiki page has been updated by {{author}}." gui_validation_error: 1 error gui_validation_error_plural: "{{count}} errors" @@ -670,6 +674,8 @@ en: label_ascending: Ascending label_descending: Descending label_date_from_to: From {{start}} to {{end}} + label_wiki_content_added: Wiki page added + label_wiki_content_updated: Wiki page updated button_login: Login button_submit: Submit diff --git a/config/locales/es.yml b/config/locales/es.yml index 812a8059d..ff61e7d9e 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -843,3 +843,9 @@ es: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/fi.yml b/config/locales/fi.yml index b988ef394..a1cf5cbe7 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -833,3 +833,9 @@ fi: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/fr.yml b/config/locales/fr.yml index e4d471019..bbe18dca6 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -181,6 +181,10 @@ fr: mail_body_account_activation_request: "Un nouvel utilisateur ({{value}}) s'est inscrit. Son compte nécessite votre approbation:" mail_subject_reminder: "{{count}} demande(s) arrivent à échéance" mail_body_reminder: "{{count}} demande(s) qui vous sont assignées arrivent à échéance dans les {{days}} prochains jours:" + mail_subject_wiki_content_added: "Page wiki '{{page}}' ajoutée" + mail_body_wiki_content_added: "La page wiki '{{page}}' a été ajoutée par {{author}}." + mail_subject_wiki_content_updated: "Page wiki '{{page}}' mise à jour" + mail_body_wiki_content_updated: "La page wiki '{{page}}' a été mise à jour par {{author}}." gui_validation_error: 1 erreur gui_validation_error_plural: "{{count}} erreurs" @@ -700,6 +704,8 @@ fr: label_ascending: Croissant label_descending: Décroissant label_date_from_to: Du {{start}} au {{end}} + label_wiki_content_added: Page wiki ajoutée + label_wiki_content_updated: Page wiki mise à jour button_login: Connexion button_submit: Soumettre diff --git a/config/locales/gl.yml b/config/locales/gl.yml index 08fe8f563..167310e42 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -822,3 +822,9 @@ gl: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/he.yml b/config/locales/he.yml index 8e617286f..a720e4c26 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -805,3 +805,9 @@ he: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/hu.yml b/config/locales/hu.yml index 117d0f78f..2e0b80439 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -828,3 +828,9 @@ text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/it.yml b/config/locales/it.yml index f04e61ba0..935c38149 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -808,3 +808,9 @@ it: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 49f57b569..a9024f2ed 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -821,3 +821,9 @@ ja: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/ko.yml b/config/locales/ko.yml index c98381856..221c524be 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -852,3 +852,9 @@ ko: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/lt.yml b/config/locales/lt.yml index fdc978b70..7ba666e15 100644 --- a/config/locales/lt.yml +++ b/config/locales/lt.yml @@ -833,3 +833,9 @@ lt: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/nl.yml b/config/locales/nl.yml index cf16950e0..00229a81a 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -778,3 +778,9 @@ nl: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/no.yml b/config/locales/no.yml index 04b618ac9..ed9309eb1 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -795,3 +795,9 @@ text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 49d7ec7d9..1a20ffa49 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -826,3 +826,9 @@ pl: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index e8de22fb4..6592f6cec 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -828,3 +828,9 @@ pt-BR: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/pt.yml b/config/locales/pt.yml index e43609be3..ffc2795d2 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -814,3 +814,9 @@ pt: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/ro.yml b/config/locales/ro.yml index 31bcf70fd..7e5f098fd 100644 --- a/config/locales/ro.yml +++ b/config/locales/ro.yml @@ -793,3 +793,9 @@ ro: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/ru.yml b/config/locales/ru.yml index e55699a86..8b0605bbc 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -920,3 +920,9 @@ ru: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/sk.yml b/config/locales/sk.yml index 722ee545d..dd23496b9 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -794,3 +794,9 @@ sk: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/sl.yml b/config/locales/sl.yml index becf2c621..f3f4d2fa8 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -792,3 +792,9 @@ sl: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/sr.yml b/config/locales/sr.yml index d29b83fb9..ed56fda99 100644 --- a/config/locales/sr.yml +++ b/config/locales/sr.yml @@ -816,3 +816,9 @@ text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/sv.yml b/config/locales/sv.yml index be8b58900..3a7add901 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -850,3 +850,9 @@ sv: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/th.yml b/config/locales/th.yml index 56382db22..a24682700 100644 --- a/config/locales/th.yml +++ b/config/locales/th.yml @@ -793,3 +793,9 @@ th: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/tr.yml b/config/locales/tr.yml index ecfdba74a..c167d9215 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -829,3 +829,9 @@ tr: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/uk.yml b/config/locales/uk.yml index 148642b66..719b2c3f5 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -792,3 +792,9 @@ uk: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/vi.yml b/config/locales/vi.yml index 7b3238a8f..b981752ce 100644 --- a/config/locales/vi.yml +++ b/config/locales/vi.yml @@ -862,3 +862,9 @@ vi: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index de037c8e9..1c84c9931 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -900,3 +900,9 @@ text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/config/locales/zh.yml b/config/locales/zh.yml index f42975f45..3145d303a 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -825,3 +825,9 @@ zh: text_wiki_page_destroy_children: Delete child pages and all their descendants setting_password_min_length: Minimum password length field_group_by: Group results by + mail_subject_wiki_content_updated: "'{{page}}' wiki page has been updated" + label_wiki_content_added: Wiki page added + mail_subject_wiki_content_added: "'{{page}}' wiki page has been added" + mail_body_wiki_content_added: The '{{page}}' wiki page has been added by {{author}}. + label_wiki_content_updated: Wiki page updated + mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}. diff --git a/test/unit/wiki_content_test.rb b/test/unit/wiki_content_test.rb index a8c28ae21..f3f8bc041 100644 --- a/test/unit/wiki_content_test.rb +++ b/test/unit/wiki_content_test.rb @@ -40,6 +40,16 @@ class WikiContentTest < Test::Unit::TestCase assert_equal User.find(1), content.author assert_equal content.text, content.versions.last.text end + + def test_create_should_send_email_notification + Setting.notified_events = ['wiki_content_added'] + ActionMailer::Base.deliveries.clear + page = WikiPage.new(:wiki => @wiki, :title => "A new page") + page.content = WikiContent.new(:text => "Content text", :author => User.find(1), :comments => "My comment") + assert page.save + + assert_equal 1, ActionMailer::Base.deliveries.size + end def test_update content = @page.content @@ -51,6 +61,16 @@ class WikiContentTest < Test::Unit::TestCase assert_equal version_count+1, content.versions.length end + def test_update_should_send_email_notification + Setting.notified_events = ['wiki_content_updated'] + ActionMailer::Base.deliveries.clear + content = @page.content + content.text = "My new content" + assert content.save + + assert_equal 1, ActionMailer::Base.deliveries.size + end + def test_fetch_history assert !@page.content.versions.empty? @page.content.versions.each do |version|