mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-26 02:11:15 +00:00
Backported r3608 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/0.9-stable@3642 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
30c45a6187
commit
3e6f42e46d
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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) %>
|
||||
|
||||
@ -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
|
||||
|
||||
label_project_copy_notifications: Send email notifications during the project copy
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
label_project_copy_notifications: Send email notifications during the project copy
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
label_project_copy_notifications: Send email notifications during the project copy
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user