summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2010-04-11 14:20:40 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2010-04-11 14:20:40 +0000
commit3e6f42e46d43650b6f561849d0bfaf0f0e018bf6 (patch)
treea467f3553c0604e9ffc9af8cb421633f0c8deb30
parent30c45a6187227a30cf85bc4063ba793c47c53768 (diff)
downloadredmine-3e6f42e46d43650b6f561849d0bfaf0f0e018bf6.tar.gz
redmine-3e6f42e46d43650b6f561849d0bfaf0f0e018bf6.zip
Backported r3608 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/0.9-stable@3642 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/projects_controller.rb26
-rw-r--r--app/models/mailer.rb9
-rw-r--r--app/views/projects/copy.rhtml2
-rw-r--r--config/locales/bg.yml2
-rw-r--r--config/locales/bs.yml1
-rw-r--r--config/locales/ca.yml1
-rw-r--r--config/locales/cs.yml1
-rw-r--r--config/locales/da.yml1
-rw-r--r--config/locales/de.yml1
-rw-r--r--config/locales/el.yml1
-rw-r--r--config/locales/en.yml1
-rw-r--r--config/locales/es.yml1
-rw-r--r--config/locales/fi.yml1
-rw-r--r--config/locales/fr.yml1
-rw-r--r--config/locales/gl.yml1
-rw-r--r--config/locales/he.yml1
-rw-r--r--config/locales/hr.yml1
-rw-r--r--config/locales/hu.yml1
-rw-r--r--config/locales/id.yml1
-rw-r--r--config/locales/it.yml2
-rw-r--r--config/locales/ja.yml1
-rw-r--r--config/locales/ko.yml1
-rw-r--r--config/locales/lt.yml1
-rw-r--r--config/locales/nl.yml1
-rw-r--r--config/locales/no.yml1
-rw-r--r--config/locales/pl.yml1
-rw-r--r--config/locales/pt-BR.yml1
-rw-r--r--config/locales/pt.yml1
-rw-r--r--config/locales/ro.yml1
-rw-r--r--config/locales/ru.yml1
-rw-r--r--config/locales/sk.yml1
-rw-r--r--config/locales/sl.yml1
-rw-r--r--config/locales/sr.yml1
-rw-r--r--config/locales/sv.yml1
-rw-r--r--config/locales/th.yml1
-rw-r--r--config/locales/tr.yml1
-rw-r--r--config/locales/uk.yml1
-rw-r--r--config/locales/vi.yml1
-rw-r--r--config/locales/zh-TW.yml1
-rw-r--r--config/locales/zh.yml2
-rw-r--r--test/unit/mailer_test.rb23
41 files changed, 85 insertions, 15 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index ec22e2206..cb041b9ea 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -102,18 +102,20 @@ class ProjectsController < ApplicationController
redirect_to :controller => 'admin', :action => 'projects'
end
else
- @project = Project.new(params[:project])
- @project.enabled_module_names = params[:enabled_modules]
- if validate_parent_id && @project.copy(@source_project, :only => params[:only])
- @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
- flash[:notice] = l(:notice_successful_create)
- redirect_to :controller => 'admin', :action => 'projects'
- elsif !@project.new_record?
- # Project was created
- # But some objects were not copied due to validation failures
- # (eg. issues from disabled trackers)
- # TODO: inform about that
- redirect_to :controller => 'admin', :action => 'projects'
+ Mailer.with_deliveries(params[:notifications] == '1') do
+ @project = Project.new(params[:project])
+ @project.enabled_module_names = params[:enabled_modules]
+ if validate_parent_id && @project.copy(@source_project, :only => params[:only])
+ @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
+ flash[:notice] = l(:notice_successful_create)
+ redirect_to :controller => 'admin', :action => 'projects'
+ elsif !@project.new_record?
+ # Project was created
+ # But some objects were not copied due to validation failures
+ # (eg. issues from disabled trackers)
+ # TODO: inform about that
+ redirect_to :controller => 'admin', :action => 'projects'
+ end
end
end
rescue ActiveRecord::RecordNotFound
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 9c409af69..e987c8a87 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -310,6 +310,15 @@ class Mailer < ActionMailer::Base
deliver_reminder(assignee, issues, days) unless assignee.nil?
end
end
+
+ # Activates/desactivates email deliveries during +block+
+ def self.with_deliveries(enabled = true, &block)
+ was_enabled = ActionMailer::Base.perform_deliveries
+ ActionMailer::Base.perform_deliveries = !!enabled
+ yield
+ ensure
+ ActionMailer::Base.perform_deliveries = was_enabled
+ end
private
def initialize_defaults(method_name)
diff --git a/app/views/projects/copy.rhtml b/app/views/projects/copy.rhtml
index 49e262786..dfcd44339 100644
--- a/app/views/projects/copy.rhtml
+++ b/app/views/projects/copy.rhtml
@@ -21,6 +21,8 @@
<label class="block"><%= check_box_tag 'only[]', 'boards', true %> <%= l(:label_board_plural) %> (<%= @source_project.boards.count %>)</label>
<label class="block"><%= check_box_tag 'only[]', 'wiki', true %> <%= l(:label_wiki_page_plural) %> (<%= @source_project.wiki.nil? ? 0 : @source_project.wiki.pages.count %>)</label>
<%= hidden_field_tag 'only[]', '' %>
+ <br />
+ <label class="block"><%= check_box_tag 'notifications', 1, params[:notifications] %> <%= l(:label_project_copy_notifications) %></label>
</fieldset>
<%= submit_tag l(:button_copy) %>
diff --git a/config/locales/bg.yml b/config/locales/bg.yml
index 2a68101e4..30153d6e4 100644
--- a/config/locales/bg.yml
+++ b/config/locales/bg.yml
@@ -881,4 +881,4 @@ bg:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
- \ No newline at end of file
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/bs.yml b/config/locales/bs.yml
index edfd1f6f2..623e0fe03 100644
--- a/config/locales/bs.yml
+++ b/config/locales/bs.yml
@@ -905,3 +905,4 @@ bs:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/ca.yml b/config/locales/ca.yml
index 12d36328f..2ef4fc28a 100644
--- a/config/locales/ca.yml
+++ b/config/locales/ca.yml
@@ -884,3 +884,4 @@ ca:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/cs.yml b/config/locales/cs.yml
index 202ba3b2b..96f9b8d96 100644
--- a/config/locales/cs.yml
+++ b/config/locales/cs.yml
@@ -887,3 +887,4 @@ cs:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/da.yml b/config/locales/da.yml
index ff76caa45..a6677859a 100644
--- a/config/locales/da.yml
+++ b/config/locales/da.yml
@@ -907,3 +907,4 @@ da:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/de.yml b/config/locales/de.yml
index f3d87fd8f..b284285d3 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -907,3 +907,4 @@ de:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/el.yml b/config/locales/el.yml
index 5ab7e6280..84a0c52cd 100644
--- a/config/locales/el.yml
+++ b/config/locales/el.yml
@@ -887,3 +887,4 @@ el:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 2ee57bcf9..267a419b0 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -748,6 +748,7 @@ en:
label_api_access_key: API access key
label_missing_api_access_key: Missing an API access key
label_api_access_key_created_on: "API access key created {{value}} ago"
+ label_project_copy_notifications: Send email notifications during the project copy
button_login: Login
button_submit: Submit
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 5c77c71c6..e24c5e3cf 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -931,3 +931,4 @@ es:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/fi.yml b/config/locales/fi.yml
index d26c9852b..a6bbfd3a1 100644
--- a/config/locales/fi.yml
+++ b/config/locales/fi.yml
@@ -917,3 +917,4 @@ fi:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index 636a588f6..67788f412 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -764,6 +764,7 @@ fr:
label_missing_feeds_access_key: Clé d'accès RSS manquante
label_close_versions: Fermer les versions terminées
label_revision_id: Revision {{value}}
+ label_project_copy_notifications: Envoyer les notifications durant la copie du projet
button_login: Connexion
button_submit: Soumettre
diff --git a/config/locales/gl.yml b/config/locales/gl.yml
index 92356c343..b55db506f 100644
--- a/config/locales/gl.yml
+++ b/config/locales/gl.yml
@@ -907,3 +907,4 @@ gl:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/he.yml b/config/locales/he.yml
index eb068f7a2..90c8f6560 100644
--- a/config/locales/he.yml
+++ b/config/locales/he.yml
@@ -891,3 +891,4 @@ he:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/hr.yml b/config/locales/hr.yml
index b7b70b5c4..e662fa309 100644
--- a/config/locales/hr.yml
+++ b/config/locales/hr.yml
@@ -894,3 +894,4 @@ hr:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/hu.yml b/config/locales/hu.yml
index 99a475e9c..403567478 100644
--- a/config/locales/hu.yml
+++ b/config/locales/hu.yml
@@ -912,3 +912,4 @@
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/id.yml b/config/locales/id.yml
index 79e4d36c4..86510580b 100644
--- a/config/locales/id.yml
+++ b/config/locales/id.yml
@@ -899,3 +899,4 @@ id:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/it.yml b/config/locales/it.yml
index 4e52a3df5..c045f4da3 100644
--- a/config/locales/it.yml
+++ b/config/locales/it.yml
@@ -894,4 +894,4 @@ it:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
- \ No newline at end of file
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/ja.yml b/config/locales/ja.yml
index ce5d87efa..01e24dca2 100644
--- a/config/locales/ja.yml
+++ b/config/locales/ja.yml
@@ -916,3 +916,4 @@ ja:
enumeration_activities: 作業分類 (時間トラッキング)
enumeration_system_activity: システム作業分類
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/ko.yml b/config/locales/ko.yml
index 7d389a9d1..589728d6d 100644
--- a/config/locales/ko.yml
+++ b/config/locales/ko.yml
@@ -947,3 +947,4 @@ ko:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/lt.yml b/config/locales/lt.yml
index 4c5be32b0..8defdf177 100644
--- a/config/locales/lt.yml
+++ b/config/locales/lt.yml
@@ -955,3 +955,4 @@ lt:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/nl.yml b/config/locales/nl.yml
index bb2b8dd1e..1e517f82e 100644
--- a/config/locales/nl.yml
+++ b/config/locales/nl.yml
@@ -869,3 +869,4 @@ nl:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/no.yml b/config/locales/no.yml
index ee8463317..5749866d0 100644
--- a/config/locales/no.yml
+++ b/config/locales/no.yml
@@ -882,3 +882,4 @@
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/pl.yml b/config/locales/pl.yml
index 2492e6e2d..0fd4108b2 100644
--- a/config/locales/pl.yml
+++ b/config/locales/pl.yml
@@ -912,3 +912,4 @@ pl:
permission_export_wiki_pages: Eksport stron wiki
permission_manage_project_activities: Zarządzanie aktywnościami projektu
setting_cache_formatted_text: Cache formatted text
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml
index a70827329..07fadd6b3 100644
--- a/config/locales/pt-BR.yml
+++ b/config/locales/pt-BR.yml
@@ -915,3 +915,4 @@ pt-BR:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/pt.yml b/config/locales/pt.yml
index 7c22dff0b..ce0a8e103 100644
--- a/config/locales/pt.yml
+++ b/config/locales/pt.yml
@@ -899,3 +899,4 @@ pt:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/ro.yml b/config/locales/ro.yml
index d7b115efd..ead91bb98 100644
--- a/config/locales/ro.yml
+++ b/config/locales/ro.yml
@@ -884,3 +884,4 @@ ro:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/ru.yml b/config/locales/ru.yml
index 2017f62fd..b086505db 100644
--- a/config/locales/ru.yml
+++ b/config/locales/ru.yml
@@ -995,3 +995,4 @@ ru:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/sk.yml b/config/locales/sk.yml
index f2baf5108..be9ae10a0 100644
--- a/config/locales/sk.yml
+++ b/config/locales/sk.yml
@@ -886,3 +886,4 @@ sk:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/sl.yml b/config/locales/sl.yml
index 2d5279f15..f54c20285 100644
--- a/config/locales/sl.yml
+++ b/config/locales/sl.yml
@@ -883,3 +883,4 @@ sl:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/sr.yml b/config/locales/sr.yml
index 135715f36..32d2aa561 100644
--- a/config/locales/sr.yml
+++ b/config/locales/sr.yml
@@ -902,3 +902,4 @@
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/sv.yml b/config/locales/sv.yml
index c073b93ad..340137aa7 100644
--- a/config/locales/sv.yml
+++ b/config/locales/sv.yml
@@ -936,3 +936,4 @@ sv:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/th.yml b/config/locales/th.yml
index 557ad2cf2..5bf4b5611 100644
--- a/config/locales/th.yml
+++ b/config/locales/th.yml
@@ -884,3 +884,4 @@ th:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/tr.yml b/config/locales/tr.yml
index c90661a49..5f49d6fb6 100644
--- a/config/locales/tr.yml
+++ b/config/locales/tr.yml
@@ -914,3 +914,4 @@ tr:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/uk.yml b/config/locales/uk.yml
index f4e012d50..522381c3d 100644
--- a/config/locales/uk.yml
+++ b/config/locales/uk.yml
@@ -883,3 +883,4 @@ uk:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/vi.yml b/config/locales/vi.yml
index 5dfb5049c..49dae7c11 100644
--- a/config/locales/vi.yml
+++ b/config/locales/vi.yml
@@ -946,3 +946,4 @@ vi:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml
index 4a64e2e41..6db500a8d 100644
--- a/config/locales/zh-TW.yml
+++ b/config/locales/zh-TW.yml
@@ -978,3 +978,4 @@
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index 3e87d0adc..361d9cf25 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -909,4 +909,4 @@ zh:
permission_export_wiki_pages: Export wiki pages
setting_cache_formatted_text: Cache formatted text
permission_manage_project_activities: Manage project activities
- \ No newline at end of file
+ label_project_copy_notifications: Send email notifications during the project copy
diff --git a/test/unit/mailer_test.rb b/test/unit/mailer_test.rb
index fbbff1a03..3ce33e6fb 100644
--- a/test/unit/mailer_test.rb
+++ b/test/unit/mailer_test.rb
@@ -21,6 +21,12 @@ class MailerTest < ActiveSupport::TestCase
include Redmine::I18n
include ActionController::Assertions::SelectorAssertions
fixtures :projects, :enabled_modules, :issues, :users, :members, :member_roles, :roles, :documents, :attachments, :news, :tokens, :journals, :journal_details, :changesets, :trackers, :issue_statuses, :enumerations, :messages, :boards, :repositories
+
+ def setup
+ ActionMailer::Base.deliveries.clear
+ Setting.host_name = 'mydomain.foo'
+ Setting.protocol = 'http'
+ end
def test_generated_links_in_emails
ActionMailer::Base.deliveries.clear
@@ -282,6 +288,14 @@ class MailerTest < ActiveSupport::TestCase
end
end
+ def test_test
+ user = User.find(1)
+ valid_languages.each do |lang|
+ user.update_attribute :language, lang.to_s
+ assert Mailer.deliver_test(user)
+ end
+ end
+
def test_reminders
ActionMailer::Base.deliveries.clear
Mailer.reminders(:days => 42)
@@ -310,4 +324,13 @@ class MailerTest < ActiveSupport::TestCase
assert_equal :it, current_language
end
+
+ def test_with_deliveries_off
+ Mailer.with_deliveries false do
+ Mailer.deliver_test(User.find(1))
+ end
+ assert ActionMailer::Base.deliveries.empty?
+ # should restore perform_deliveries
+ assert ActionMailer::Base.perform_deliveries
+ end
end