]> source.dussan.org Git - redmine.git/commitdiff
Backported r3608 from trunk.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 11 Apr 2010 14:20:40 +0000 (14:20 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 11 Apr 2010 14:20:40 +0000 (14:20 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/0.9-stable@3642 e93f8b46-1217-0410-a6f0-8f06a7374b81

41 files changed:
app/controllers/projects_controller.rb
app/models/mailer.rb
app/views/projects/copy.rhtml
config/locales/bg.yml
config/locales/bs.yml
config/locales/ca.yml
config/locales/cs.yml
config/locales/da.yml
config/locales/de.yml
config/locales/el.yml
config/locales/en.yml
config/locales/es.yml
config/locales/fi.yml
config/locales/fr.yml
config/locales/gl.yml
config/locales/he.yml
config/locales/hr.yml
config/locales/hu.yml
config/locales/id.yml
config/locales/it.yml
config/locales/ja.yml
config/locales/ko.yml
config/locales/lt.yml
config/locales/nl.yml
config/locales/no.yml
config/locales/pl.yml
config/locales/pt-BR.yml
config/locales/pt.yml
config/locales/ro.yml
config/locales/ru.yml
config/locales/sk.yml
config/locales/sl.yml
config/locales/sr.yml
config/locales/sv.yml
config/locales/th.yml
config/locales/tr.yml
config/locales/uk.yml
config/locales/vi.yml
config/locales/zh-TW.yml
config/locales/zh.yml
test/unit/mailer_test.rb

index ec22e2206edcca24a89d6cd69e6f02098d3ca12a..cb041b9ea5d48f15f974040a6abc4829af29d1d6 100644 (file)
@@ -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
index 9c409af696705231e957eadacc1d5744d010d267..e987c8a87ae1775c7232a9d8f6ab21591eac9ea0 100644 (file)
@@ -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)
index 49e262786453ca92426827229ed2ae9288c397d0..dfcd44339ce30ab5cf4299d6379d5dc38055a5d6 100644 (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) %>
index 2a68101e4b4ec3e3be5a87653966baf2df35447b..30153d6e4664f2a177eaf04e5d34e6656e364333 100644 (file)
@@ -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
index edfd1f6f23417b26af3f36e005f01e22e1e23a86..623e0fe03fcc95d6f1e0afd58adb09a76560fee2 100644 (file)
@@ -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
index 12d36328f57c7db9c2a86372e858a93ca227c0f2..2ef4fc28a782364084d8ac48e567ac552def4e97 100644 (file)
@@ -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
index 202ba3b2b9d4eda9b6bb999356427ac62d0f421c..96f9b8d9640dc8d27b095e8ff93039c1e9cb54da 100644 (file)
@@ -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
index ff76caa45aa66b0b9a3a427a2663dedce5aeaf6b..a6677859a2a902bdeddd41375e39a234ba1f44bd 100644 (file)
@@ -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
index f3d87fd8f2c412bb02feb3782a5f289db9a5a74b..b284285d323668a088c7c14a835b18409b4e7fa6 100644 (file)
@@ -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
index 5ab7e62801bd9b5c7199a3d21a2350a062f2e13d..84a0c52cde107f76d83037372dc333cf810e7cd2 100644 (file)
@@ -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
index 2ee57bcf9f6c12092f591c0659d1e39d17bd90d1..267a419b0f6efcd0571bdf7a4060ee21c313387c 100644 (file)
@@ -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
index 5c77c71c6968e7ac181fe1fd575e9749e482d76a..e24c5e3cf93c9e9ebbb6f9b695a0233124be9668 100644 (file)
@@ -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
index d26c9852b9b1d081dea4285a230751d946eaa06e..a6bbfd3a112c0d8120ab2c868bd9c46ecba16296 100644 (file)
@@ -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
index 636a588f6d1ef5dab91440a31134cdf2db9424c4..67788f412f300aa3b0095cee5882a7632f661d10 100644 (file)
@@ -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
index 92356c343dd327bae9aff14d4658ba5e3a9c2313..b55db506fe5fdf528de4ff09f220249be54526a8 100644 (file)
@@ -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
index eb068f7a2fc97a3bbe55fe0ff7fd97335dc3a337..90c8f656092431d89984a4f01b46a410f539a509 100644 (file)
@@ -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
index b7b70b5c4f9acf5b80a9e1697e1ed894863fdcf3..e662fa30936037f4a6054f3ca8385e1889078eec 100644 (file)
@@ -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
index 99a475e9ce4a095d3db4d6694c2ae6e2982fdf00..403567478bfb8a12702d44e0fb8448919698040a 100644 (file)
   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
index 79e4d36c4c0a7b79dffaa3885882c024a59fec17..86510580b42fda83eb7613bc2155bcec2830d3a7 100644 (file)
@@ -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
index 4e52a3df5a92250164879b6451f624c77d2b8137..c045f4da3ba26274136d6f1dd5173f8d00afa438 100644 (file)
@@ -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
index ce5d87efa04c4cf05e835cb4bb67608f9cb6f070..01e24dca28014ffb7b6881c9a5d3859ff195b09d 100644 (file)
@@ -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
index 7d389a9d14bd7716a2e17f5b3d81f30155d37e38..589728d6d3256b8eef7f9cbb3e0314878a9a73f5 100644 (file)
@@ -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
index 4c5be32b06c1c08d1b7883793f490f431750781d..8defdf177c19eecda982afa723fae113c2a7c0f6 100644 (file)
@@ -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
index bb2b8dd1e54abbad4b07d54c20019609c1cec1d5..1e517f82e8cb0098c1c8b5d36759ec50086e06b3 100644 (file)
@@ -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
index ee8463317e7ee088c4640d0b54f8b074204ec7a3..5749866d0ea2fa41ad100840419e6ac15c8387db 100644 (file)
   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
index 2492e6e2d714ec3d18cf33cdd505e28d85e3c210..0fd4108b2e201afada47808454c061377a1faa49 100644 (file)
@@ -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
index a70827329a82496c6e04d21e5c1bb2e7060942be..07fadd6b3941570792f6d99b932fd128d4cf6031 100644 (file)
@@ -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
index 7c22dff0b8e1aea54b4f4b4521e633959b1aafcc..ce0a8e103256c9977c9bbea62b01b163724bbf7f 100644 (file)
@@ -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
index d7b115efd686357796d70b438e8e03e139b1cbcc..ead91bb986df44d5f6699f230fbabf20b1cccf01 100644 (file)
@@ -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
index 2017f62fd03fa354fded913c2c40cd0e86a76e7e..b086505dbef0f4fe42d2697ed35a3aa314e14d09 100644 (file)
@@ -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
index f2baf5108c9f5e2b82352bf95f11fa68230abdd9..be9ae10a0d9e6be128e88e4d0c28655f1d645609 100644 (file)
@@ -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
index 2d5279f157b40659ca9c377fd271684efc57bcbd..f54c20285f66ccf6a66be79a07c0a3aa86644724 100644 (file)
@@ -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
index 135715f365be03ed9e7dc30659db1e42b0955231..32d2aa5611b39bcbfe36143c9d66ab903636d282 100644 (file)
   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
index c073b93add4b4e1345124b61d96c78473bb255da..340137aa7cbac7c1f5c479b69bca43aea3d8828c 100644 (file)
@@ -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
index 557ad2cf2808b09f90ddc1e6ecd6fccab7b47cc7..5bf4b56117745801ae6b799ba872214ef1df4299 100644 (file)
@@ -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
index c90661a490f0c988746680306122aca6aa66b0e2..5f49d6fb6ec00307e7d4a98aca29e9faa5269740 100644 (file)
@@ -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
index f4e012d5090c3bf1a62dfd8584ec5cc6abfcc935..522381c3dbb7f5ae46206dc1d7ef2c14bd1141e5 100644 (file)
@@ -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
index 5dfb5049c71dcd96ff23d96ca2c57ab10c90ac44..49dae7c115bec6c3738449265580e1b499a8e8b6 100644 (file)
@@ -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
index 4a64e2e41f14bd4b60c3e949bf520b98f815f16d..6db500a8d07004cca8b5c5051e8d08119fd58e95 100644 (file)
   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
index 3e87d0adc7c113a17b45d8a5b0465c3eced1b9c2..361d9cf25678d7433da4ea764df4f0fc9ab14413 100644 (file)
@@ -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
index fbbff1a03073313593ac7b31370759009067789f..3ce33e6fb00b887d602f809a6e6687effd31092d 100644 (file)
@@ -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