@@ -187,22 +187,22 class IssuesController < ApplicationController | |||
|
187 | 187 | if request.post? |
|
188 | 188 | @time_entry = TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => Date.today) |
|
189 | 189 | @time_entry.attributes = params[:time_entry] |
|
190 | attachments = attach_files(@issue, params[:attachments]) | |
|
191 | attachments.each {|a| journal.details << JournalDetail.new(:property => 'attachment', :prop_key => a.id, :value => a.filename)} | |
|
192 | ||
|
193 | call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal}) | |
|
194 | ||
|
195 | if (@time_entry.hours.nil? || @time_entry.valid?) && @issue.save | |
|
196 | # Log spend time | |
|
197 | if User.current.allowed_to?(:log_time, @project) | |
|
198 |
|
|
|
199 | end | |
|
200 | if !journal.new_record? | |
|
201 | # Only send notification if something was actually changed | |
|
202 | flash[:notice] = l(:notice_successful_update) | |
|
190 | if (@time_entry.hours.nil? || @time_entry.valid?) && @issue.valid? | |
|
191 | attachments = attach_files(@issue, params[:attachments]) | |
|
192 | attachments.each {|a| journal.details << JournalDetail.new(:property => 'attachment', :prop_key => a.id, :value => a.filename)} | |
|
193 | call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal}) | |
|
194 | if @issue.save | |
|
195 | # Log spend time | |
|
196 | if User.current.allowed_to?(:log_time, @project) | |
|
197 | @time_entry.save | |
|
198 | end | |
|
199 | if !journal.new_record? | |
|
200 | # Only send notification if something was actually changed | |
|
201 | flash[:notice] = l(:notice_successful_update) | |
|
202 | end | |
|
203 | call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal}) | |
|
204 | redirect_back_or_default({:action => 'show', :id => @issue}) | |
|
203 | 205 | end |
|
204 | call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal}) | |
|
205 | redirect_back_or_default({:action => 'show', :id => @issue}) | |
|
206 | 206 | end |
|
207 | 207 | end |
|
208 | 208 | rescue ActiveRecord::StaleObjectError |
@@ -62,8 +62,8 class SearchController < ApplicationController | |||
|
62 | 62 | # extract tokens from the question |
|
63 | 63 | # eg. hello "bye bye" => ["hello", "bye bye"] |
|
64 | 64 | @tokens = @question.scan(%r{((\s|^)"[\s\w]+"(\s|$)|\S+)}).collect {|m| m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, '')} |
|
65 |
# tokens must be at least |
|
|
66 |
@tokens = @tokens.uniq.select {|w| w.length > |
|
|
65 | # tokens must be at least 2 characters long | |
|
66 | @tokens = @tokens.uniq.select {|w| w.length > 1 } | |
|
67 | 67 | |
|
68 | 68 | if !@tokens.empty? |
|
69 | 69 | # no more than 5 tokens to search for |
@@ -91,8 +91,8 module IssuesHelper | |||
|
91 | 91 | c = IssueCategory.find_by_id(detail.value) and value = c.name if detail.value |
|
92 | 92 | c = IssueCategory.find_by_id(detail.old_value) and old_value = c.name if detail.old_value |
|
93 | 93 | when 'fixed_version_id' |
|
94 |
v = Version.find_by_id(detail.value) and value = |
|
|
95 |
v = Version.find_by_id(detail.old_value) and old_value = |
|
|
94 | v = Version.find_by_id(detail.value) and value = v.name if detail.value | |
|
95 | v = Version.find_by_id(detail.old_value) and old_value = v.name if detail.old_value | |
|
96 | 96 | when 'estimated_hours' |
|
97 | 97 | value = "%0.02f" % detail.value.to_f unless detail.value.blank? |
|
98 | 98 | old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank? |
@@ -272,6 +272,7 class Mailer < ActionMailer::Base | |||
|
272 | 272 | # Overrides default deliver! method to prevent from sending an email |
|
273 | 273 | # with no recipient, cc or bcc |
|
274 | 274 | def deliver!(mail = @mail) |
|
275 | set_language_if_valid @initial_language | |
|
275 | 276 | return false if (recipients.nil? || recipients.empty?) && |
|
276 | 277 | (cc.nil? || cc.empty?) && |
|
277 | 278 | (bcc.nil? || bcc.empty?) |
@@ -313,6 +314,7 class Mailer < ActionMailer::Base | |||
|
313 | 314 | private |
|
314 | 315 | def initialize_defaults(method_name) |
|
315 | 316 | super |
|
317 | @initial_language = current_language | |
|
316 | 318 | set_language_if_valid Setting.default_language |
|
317 | 319 | from Setting.mail_from |
|
318 | 320 |
@@ -20,7 +20,7 require File.dirname(__FILE__) + '/../test_helper' | |||
|
20 | 20 | class MailerTest < ActiveSupport::TestCase |
|
21 | 21 | include Redmine::I18n |
|
22 | 22 | include ActionController::Assertions::SelectorAssertions |
|
23 | fixtures :projects, :issues, :users, :members, :member_roles, :documents, :attachments, :news, :tokens, :journals, :journal_details, :changesets, :trackers, :issue_statuses, :enumerations, :messages, :boards, :repositories | |
|
23 | 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 | |
|
24 | 24 | |
|
25 | 25 | def test_generated_links_in_emails |
|
26 | 26 | ActionMailer::Base.deliveries.clear |
@@ -296,4 +296,18 class MailerTest < ActiveSupport::TestCase | |||
|
296 | 296 | assert_not_nil mail |
|
297 | 297 | |
|
298 | 298 | end |
|
299 | ||
|
300 | def test_mailer_should_not_change_locale | |
|
301 | Setting.default_language = 'en' | |
|
302 | # Set current language to italian | |
|
303 | set_language_if_valid 'it' | |
|
304 | # Send an email to a french user | |
|
305 | user = User.find(1) | |
|
306 | user.language = 'fr' | |
|
307 | Mailer.deliver_account_activated(user) | |
|
308 | mail = ActionMailer::Base.deliveries.last | |
|
309 | assert mail.body.include?('Votre compte') | |
|
310 | ||
|
311 | assert_equal :it, current_language | |
|
312 | end | |
|
299 | 313 | end |
General Comments 0
You need to be logged in to leave comments.
Login now