1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-19 15:01:14 +00:00

Merged r3305, r3306, r3307, r3311 from trunk.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/0.9-stable@3317 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2010-01-16 13:57:41 +00:00
parent f60881518a
commit c5a59aff5b
5 changed files with 36 additions and 20 deletions

View File

@ -187,22 +187,22 @@ class IssuesController < ApplicationController
if request.post? if request.post?
@time_entry = TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => Date.today) @time_entry = TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => Date.today)
@time_entry.attributes = params[:time_entry] @time_entry.attributes = params[:time_entry]
attachments = attach_files(@issue, params[:attachments]) if (@time_entry.hours.nil? || @time_entry.valid?) && @issue.valid?
attachments.each {|a| journal.details << JournalDetail.new(:property => 'attachment', :prop_key => a.id, :value => a.filename)} 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}) call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal})
if @issue.save
if (@time_entry.hours.nil? || @time_entry.valid?) && @issue.save # Log spend time
# Log spend time if User.current.allowed_to?(:log_time, @project)
if User.current.allowed_to?(:log_time, @project) @time_entry.save
@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 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 end
end end
rescue ActiveRecord::StaleObjectError rescue ActiveRecord::StaleObjectError

View File

@ -62,8 +62,8 @@ class SearchController < ApplicationController
# extract tokens from the question # extract tokens from the question
# eg. hello "bye bye" => ["hello", "bye bye"] # 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 = @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 must be at least 2 characters long
@tokens = @tokens.uniq.select {|w| w.length > 2 } @tokens = @tokens.uniq.select {|w| w.length > 1 }
if !@tokens.empty? if !@tokens.empty?
# no more than 5 tokens to search for # no more than 5 tokens to search for

View 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.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 c = IssueCategory.find_by_id(detail.old_value) and old_value = c.name if detail.old_value
when 'fixed_version_id' 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.value) and value = v.name 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.old_value) and old_value = v.name if detail.old_value
when 'estimated_hours' when 'estimated_hours'
value = "%0.02f" % detail.value.to_f unless detail.value.blank? 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? old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank?

View File

@ -272,6 +272,7 @@ class Mailer < ActionMailer::Base
# Overrides default deliver! method to prevent from sending an email # Overrides default deliver! method to prevent from sending an email
# with no recipient, cc or bcc # with no recipient, cc or bcc
def deliver!(mail = @mail) def deliver!(mail = @mail)
set_language_if_valid @initial_language
return false if (recipients.nil? || recipients.empty?) && return false if (recipients.nil? || recipients.empty?) &&
(cc.nil? || cc.empty?) && (cc.nil? || cc.empty?) &&
(bcc.nil? || bcc.empty?) (bcc.nil? || bcc.empty?)
@ -313,6 +314,7 @@ class Mailer < ActionMailer::Base
private private
def initialize_defaults(method_name) def initialize_defaults(method_name)
super super
@initial_language = current_language
set_language_if_valid Setting.default_language set_language_if_valid Setting.default_language
from Setting.mail_from from Setting.mail_from

View File

@ -20,7 +20,7 @@ require File.dirname(__FILE__) + '/../test_helper'
class MailerTest < ActiveSupport::TestCase class MailerTest < ActiveSupport::TestCase
include Redmine::I18n include Redmine::I18n
include ActionController::Assertions::SelectorAssertions 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 def test_generated_links_in_emails
ActionMailer::Base.deliveries.clear ActionMailer::Base.deliveries.clear
@ -296,4 +296,18 @@ class MailerTest < ActiveSupport::TestCase
assert_not_nil mail assert_not_nil mail
mail mail
end 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 end