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:
parent
5225fb70f5
commit
79b4f68176
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) %>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue