From 4baf32b166a667f26440e4f3d81cdbcedc64eaa4 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Wed, 25 Feb 2009 07:25:01 +0000 Subject: Fixing Plugin and Mailer default_url_options. Both the plugin hooks and Mailer were setting default_url_options incorrectly and causing ActionContoller::UrlWritter to cache the settings on the module (mattr_accessor) causing several url generators to fail in either the plugin hooks or the Mailer. * Replaced Mailer's use of the default_url_options accessor with the proper class method * Replaced Hook's use of the default_url_options accessor with the proper class method on the ViewListener class * Added a test to reproduce the bugs in the Mailer when a hook is registered (thanks Chaoqun Zou) #2542 git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2522 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/mailer.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'app') diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 7560e53b5..8a472b343 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -23,6 +23,12 @@ class Mailer < ActionMailer::Base include ActionController::UrlWriter include Redmine::I18n + def self.default_url_options + h = Setting.host_name + h = h.to_s.gsub(%r{\/.*$}, '') unless Redmine::Utils.relative_url_root.blank? + { :host => h, :protocol => Setting.protocol } + end + def issue_add(issue) redmine_headers 'Project' => issue.project.identifier, 'Issue-Id' => issue.id, @@ -213,12 +219,6 @@ class Mailer < ActionMailer::Base set_language_if_valid Setting.default_language from Setting.mail_from - # URL options - h = Setting.host_name - h = h.to_s.gsub(%r{\/.*$}, '') unless Redmine::Utils.relative_url_root.blank? - default_url_options[:host] = h - default_url_options[:protocol] = Setting.protocol - # Common headers headers 'X-Mailer' => 'Redmine', 'X-Redmine-Host' => Setting.host_name, -- cgit v1.2.3