]> source.dussan.org Git - redmine.git/commitdiff
Merged r3305, r3306, r3307, r3311 from trunk.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 16 Jan 2010 13:57:41 +0000 (13:57 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 16 Jan 2010 13:57:41 +0000 (13:57 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/0.9-stable@3317 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issues_controller.rb
app/controllers/search_controller.rb
app/helpers/issues_helper.rb
app/models/mailer.rb
test/unit/mailer_test.rb

index 85789e2f1e9cec2132d0403e6874777478c199ac..71e07ce0960236d5a99d4ac5529696c9d3f675dd 100644 (file)
@@ -187,22 +187,22 @@ class IssuesController < ApplicationController
     if request.post?
       @time_entry = TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => Date.today)
       @time_entry.attributes = params[:time_entry]
-      attachments = attach_files(@issue, params[:attachments])
-      attachments.each {|a| journal.details << JournalDetail.new(:property => 'attachment', :prop_key => a.id, :value => a.filename)}
-      
-      call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal})
-
-      if (@time_entry.hours.nil? || @time_entry.valid?) && @issue.save
-        # Log spend time
-        if User.current.allowed_to?(:log_time, @project)
-          @time_entry.save
-        end
-        if !journal.new_record?
-          # Only send notification if something was actually changed
-          flash[:notice] = l(:notice_successful_update)
+      if (@time_entry.hours.nil? || @time_entry.valid?) && @issue.valid?
+        attachments = attach_files(@issue, params[:attachments])
+        attachments.each {|a| journal.details << JournalDetail.new(:property => 'attachment', :prop_key => a.id, :value => a.filename)}
+        call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal})
+        if @issue.save
+          # Log spend time
+          if User.current.allowed_to?(:log_time, @project)
+            @time_entry.save
+          end
+          if !journal.new_record?
+            # Only send notification if something was actually changed
+            flash[:notice] = l(:notice_successful_update)
+          end
+          call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal})
+          redirect_back_or_default({:action => 'show', :id => @issue})
         end
-        call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal})
-        redirect_back_or_default({:action => 'show', :id => @issue})
       end
     end
   rescue ActiveRecord::StaleObjectError
index 68687347e6d2d02212de02ad53324eb23563e0a4..241da0bd860979b5cf604ae19b89b8a7b905ced1 100644 (file)
@@ -62,8 +62,8 @@ class SearchController < ApplicationController
     # extract tokens from the question
     # eg. hello "bye bye" => ["hello", "bye bye"]
     @tokens = @question.scan(%r{((\s|^)"[\s\w]+"(\s|$)|\S+)}).collect {|m| m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, '')}
-    # tokens must be at least 3 character long
-    @tokens = @tokens.uniq.select {|w| w.length > 2 }
+    # tokens must be at least 2 characters long
+    @tokens = @tokens.uniq.select {|w| w.length > 1 }
     
     if !@tokens.empty?
       # no more than 5 tokens to search for
index 1f74011cc78780d8666aec9c8a8a2c01622d3302..0f28cc064cfeb8de74a327fbaff1c801c1cf20de 100644 (file)
@@ -91,8 +91,8 @@ module IssuesHelper
         c = IssueCategory.find_by_id(detail.value) and value = c.name if detail.value
         c = IssueCategory.find_by_id(detail.old_value) and old_value = c.name if detail.old_value
       when 'fixed_version_id'
-        v = Version.find_by_id(detail.value) and value = format_version_name(v) if detail.value
-        v = Version.find_by_id(detail.old_value) and old_value = format_version_name(v) if detail.old_value
+        v = Version.find_by_id(detail.value) and value = v.name if detail.value
+        v = Version.find_by_id(detail.old_value) and old_value = v.name if detail.old_value
       when 'estimated_hours'
         value = "%0.02f" % detail.value.to_f unless detail.value.blank?
         old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank?
index dfd2737ab5af8b9f26537cb92fa949f6f6f43856..9c409af696705231e957eadacc1d5744d010d267 100644 (file)
@@ -272,6 +272,7 @@ class Mailer < ActionMailer::Base
   # Overrides default deliver! method to prevent from sending an email
   # with no recipient, cc or bcc
   def deliver!(mail = @mail)
+    set_language_if_valid @initial_language
     return false if (recipients.nil? || recipients.empty?) &&
                     (cc.nil? || cc.empty?) &&
                     (bcc.nil? || bcc.empty?)
@@ -313,6 +314,7 @@ class Mailer < ActionMailer::Base
   private
   def initialize_defaults(method_name)
     super
+    @initial_language = current_language
     set_language_if_valid Setting.default_language
     from Setting.mail_from
     
index dfc6caf883c8220ac0378f7315bda26ba978a730..fbbff1a03073313593ac7b31370759009067789f 100644 (file)
@@ -20,7 +20,7 @@ require File.dirname(__FILE__) + '/../test_helper'
 class MailerTest < ActiveSupport::TestCase
   include Redmine::I18n
   include ActionController::Assertions::SelectorAssertions
-  fixtures :projects, :issues, :users, :members, :member_roles, :documents, :attachments, :news, :tokens, :journals, :journal_details, :changesets, :trackers, :issue_statuses, :enumerations, :messages, :boards, :repositories
+  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 test_generated_links_in_emails
     ActionMailer::Base.deliveries.clear
@@ -296,4 +296,18 @@ class MailerTest < ActiveSupport::TestCase
     assert_not_nil mail
     mail
   end
+  
+  def test_mailer_should_not_change_locale
+    Setting.default_language = 'en'
+    # Set current language to italian
+    set_language_if_valid 'it'
+    # Send an email to a french user
+    user = User.find(1)
+    user.language = 'fr'
+    Mailer.deliver_account_activated(user)
+    mail = ActionMailer::Base.deliveries.last
+    assert mail.body.include?('Votre compte')
+    
+    assert_equal :it, current_language
+  end
 end