Adds an option to enable/disable email notifications during a project copy (#4672).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3608 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2010-03-21 11:17:29 +00:00
parent 5225fb70f5
commit 79b4f68176
42 changed files with 80 additions and 12 deletions

View File

@ -115,6 +115,7 @@ class ProjectsController < ApplicationController
redirect_to :controller => 'admin', :action => 'projects'
end
else
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])
@ -129,6 +130,7 @@ class ProjectsController < ApplicationController
redirect_to :controller => 'admin', :action => 'projects'
end
end
end
rescue ActiveRecord::RecordNotFound
redirect_to :controller => 'admin', :action => 'projects'
end

View File

@ -325,6 +325,15 @@ class Mailer < ActionMailer::Base
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)
super

View File

@ -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) %>

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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