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