diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 8ef3d63d7..b6ffba56a 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -115,18 +115,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 173e33c40..f39c53209 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -324,6 +324,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 @@ <%= hidden_field_tag 'only[]', '' %> +
+ <%= submit_tag l(:button_copy) %> diff --git a/config/locales/bg.yml b/config/locales/bg.yml index b82bfc39b..5b7f1850e 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -886,3 +886,4 @@ bg: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/bs.yml b/config/locales/bs.yml index 0dff54fbc..15e8a339f 100644 --- a/config/locales/bs.yml +++ b/config/locales/bs.yml @@ -910,3 +910,4 @@ bs: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 5c3e3f422..26b506912 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -889,3 +889,4 @@ ca: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/cs.yml b/config/locales/cs.yml index c1b01bac3..98c767cfc 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -892,3 +892,4 @@ cs: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/da.yml b/config/locales/da.yml index c989f78af..097defb80 100644 --- a/config/locales/da.yml +++ b/config/locales/da.yml @@ -912,3 +912,4 @@ da: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/de.yml b/config/locales/de.yml index 7b5799608..982452e58 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -909,3 +909,4 @@ de: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/el.yml b/config/locales/el.yml index c3fd80bcb..a2c8ecc48 100644 --- a/config/locales/el.yml +++ b/config/locales/el.yml @@ -892,3 +892,4 @@ el: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/en.yml b/config/locales/en.yml index f636c9d99..408267097 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -754,6 +754,7 @@ en: label_api_access_key_created_on: "API access key created {{value}} ago" label_profile: Profile label_subtask_plural: Subtasks + 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 72ccb859e..97569e3d8 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -936,3 +936,4 @@ es: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/eu.yml b/config/locales/eu.yml index 96609555a..43f0a81bb 100644 --- a/config/locales/eu.yml +++ b/config/locales/eu.yml @@ -896,3 +896,4 @@ eu: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/fi.yml b/config/locales/fi.yml index d5dab7792..714801edc 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -922,3 +922,4 @@ fi: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 35a05e6a5..121d1b216 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -769,6 +769,7 @@ fr: label_revision_id: Revision {{value}} label_profile: Profil label_subtask_plural: Sous-tâches + 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 28a6ef900..3a2e7cfda 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -912,3 +912,4 @@ gl: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/he.yml b/config/locales/he.yml index 42a1a72fd..2b40929ca 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -896,3 +896,4 @@ he: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/hr.yml b/config/locales/hr.yml index 3f6b9923b..adc838e3c 100644 --- a/config/locales/hr.yml +++ b/config/locales/hr.yml @@ -899,3 +899,4 @@ hr: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/hu.yml b/config/locales/hu.yml index 4376d96a5..9bc4375b0 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -917,3 +917,4 @@ permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/id.yml b/config/locales/id.yml index 6fa28038c..45aa1e3b2 100644 --- a/config/locales/id.yml +++ b/config/locales/id.yml @@ -904,3 +904,4 @@ id: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/it.yml b/config/locales/it.yml index 4b65da006..231ecdfcd 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -899,3 +899,4 @@ it: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 1dd3d81ea..5cd0e107c 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -921,3 +921,4 @@ ja: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/ko.yml b/config/locales/ko.yml index 00bb96433..a3c3f6a12 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -952,3 +952,4 @@ ko: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/lt.yml b/config/locales/lt.yml index 26b26626a..dba038907 100644 --- a/config/locales/lt.yml +++ b/config/locales/lt.yml @@ -960,3 +960,4 @@ lt: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 019e71143..b92189da8 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -874,3 +874,4 @@ nl: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/no.yml b/config/locales/no.yml index f15a2e6ad..38b51eeb7 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -887,3 +887,4 @@ permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 18dda44c8..5a335358c 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -917,3 +917,4 @@ pl: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + 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 8e831a24d..7a48a6e63 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -920,3 +920,4 @@ pt-BR: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 1542146f8..e320b9ff0 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -904,3 +904,4 @@ pt: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/ro.yml b/config/locales/ro.yml index 862538c48..778b5d07b 100644 --- a/config/locales/ro.yml +++ b/config/locales/ro.yml @@ -889,3 +889,4 @@ ro: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/ru.yml b/config/locales/ru.yml index d669181f4..1a35ca809 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -1013,3 +1013,4 @@ ru: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/sk.yml b/config/locales/sk.yml index 012960a8e..6a23d2d77 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -891,3 +891,4 @@ sk: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/sl.yml b/config/locales/sl.yml index 7d59294b8..305105fa2 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -888,3 +888,4 @@ sl: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/sr.yml b/config/locales/sr.yml index f02b00f5a..cebbbe4f3 100644 --- a/config/locales/sr.yml +++ b/config/locales/sr.yml @@ -907,3 +907,4 @@ permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/sv.yml b/config/locales/sv.yml index 9f3239542..fea2c237d 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -941,3 +941,4 @@ sv: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/th.yml b/config/locales/th.yml index ae487ae68..e7bbf83f3 100644 --- a/config/locales/th.yml +++ b/config/locales/th.yml @@ -889,3 +889,4 @@ th: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/tr.yml b/config/locales/tr.yml index b103dc3ef..59fae8f07 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -919,3 +919,4 @@ tr: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/uk.yml b/config/locales/uk.yml index e2efdefaa..eecd665f1 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -888,3 +888,4 @@ uk: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/vi.yml b/config/locales/vi.yml index 393559cfc..662a12db2 100644 --- a/config/locales/vi.yml +++ b/config/locales/vi.yml @@ -951,3 +951,4 @@ vi: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + 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 80b3726fe..87acf2415 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -983,3 +983,4 @@ permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + label_project_copy_notifications: Send email notifications during the project copy diff --git a/config/locales/zh.yml b/config/locales/zh.yml index f7ae0b45e..a87817946 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -914,3 +914,4 @@ zh: permission_manage_subtasks: Manage subtasks field_parent_issue: Parent task label_subtask_plural: Subtasks + 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 68b074a93..0641bab7d 100644 --- a/test/unit/mailer_test.rb +++ b/test/unit/mailer_test.rb @@ -338,6 +338,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 Mailer.reminders(:days => 42) assert_equal 1, ActionMailer::Base.deliveries.size @@ -365,4 +373,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