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
This commit is contained in:
Eric Davis
2009-02-25 07:25:01 +00:00
parent 0f68334f0b
commit 4baf32b166
3 changed files with 33 additions and 9 deletions
+8 -2
View File
@@ -60,7 +60,6 @@ module Redmine
returning [] do |response|
hls = hook_listeners(hook)
if hls.any?
default_url_options[:only_path] ||= true
hls.each {|listener| response << listener.send(hook, context)}
end
end
@@ -77,8 +76,9 @@ module Redmine
Redmine::Hook.add_listener(child)
super
end
end
# Listener class used for views hooks.
# Listeners that inherit this class will include various helpers by default.
class ViewListener < Listener
@@ -96,6 +96,12 @@ module Redmine
include ActionController::UrlWriter
include ApplicationHelper
# Default to creating links using only the path. Subclasses can
# change this default as needed
def self.default_url_options
{:only_path => true }
end
# Helper method to directly render a partial using the context:
#
# class MyHook < Redmine::Hook::ViewListener