##// END OF EJS Templates
Fixing Plugin and Mailer default_url_options....
Eric Davis -
r2458:4baf32b166a6
parent child
Show More
@@ -23,6 +23,12 class Mailer < ActionMailer::Base
23 23 include ActionController::UrlWriter
24 24 include Redmine::I18n
25 25
26 def self.default_url_options
27 h = Setting.host_name
28 h = h.to_s.gsub(%r{\/.*$}, '') unless Redmine::Utils.relative_url_root.blank?
29 { :host => h, :protocol => Setting.protocol }
30 end
31
26 32 def issue_add(issue)
27 33 redmine_headers 'Project' => issue.project.identifier,
28 34 'Issue-Id' => issue.id,
@@ -213,12 +219,6 class Mailer < ActionMailer::Base
213 219 set_language_if_valid Setting.default_language
214 220 from Setting.mail_from
215 221
216 # URL options
217 h = Setting.host_name
218 h = h.to_s.gsub(%r{\/.*$}, '') unless Redmine::Utils.relative_url_root.blank?
219 default_url_options[:host] = h
220 default_url_options[:protocol] = Setting.protocol
221
222 222 # Common headers
223 223 headers 'X-Mailer' => 'Redmine',
224 224 'X-Redmine-Host' => Setting.host_name,
@@ -60,7 +60,6 module Redmine
60 60 returning [] do |response|
61 61 hls = hook_listeners(hook)
62 62 if hls.any?
63 default_url_options[:only_path] ||= true
64 63 hls.each {|listener| response << listener.send(hook, context)}
65 64 end
66 65 end
@@ -77,8 +76,9 module Redmine
77 76 Redmine::Hook.add_listener(child)
78 77 super
79 78 end
79
80 80 end
81
81
82 82 # Listener class used for views hooks.
83 83 # Listeners that inherit this class will include various helpers by default.
84 84 class ViewListener < Listener
@@ -96,6 +96,12 module Redmine
96 96 include ActionController::UrlWriter
97 97 include ApplicationHelper
98 98
99 # Default to creating links using only the path. Subclasses can
100 # change this default as needed
101 def self.default_url_options
102 {:only_path => true }
103 end
104
99 105 # Helper method to directly render a partial using the context:
100 106 #
101 107 # class MyHook < Redmine::Hook::ViewListener
@@ -19,6 +19,8 require File.dirname(__FILE__) + '/../../../test_helper'
19 19
20 20 class Redmine::Hook::ManagerTest < Test::Unit::TestCase
21 21
22 fixtures :issues
23
22 24 # Some hooks that are manually registered in these tests
23 25 class TestHook < Redmine::Hook::ViewListener; end
24 26
@@ -64,7 +66,6 class Redmine::Hook::ManagerTest < Test::Unit::TestCase
64 66
65 67 def teardown
66 68 @hook_module.clear_listeners
67 @hook_module.default_url_options = { }
68 69 end
69 70
70 71 def test_clear_listeners
@@ -144,5 +145,22 class Redmine::Hook::ManagerTest < Test::Unit::TestCase
144 145 assert_equal 'Test hook 1 listener. Test hook 2 listener.',
145 146 @view_hook_helper.call_hook(:view_layouts_base_html_head)
146 147 end
148
149 def test_call_hook_should_not_change_the_default_url_for_email_notifications
150 issue = Issue.find(1)
151
152 ActionMailer::Base.deliveries.clear
153 Mailer.deliver_issue_add(issue)
154 mail = ActionMailer::Base.deliveries.last
155
156 @hook_module.add_listener(TestLinkToHook)
157 @hook_helper.call_hook(:view_layouts_base_html_head)
158
159 ActionMailer::Base.deliveries.clear
160 Mailer.deliver_issue_add(issue)
161 mail2 = ActionMailer::Base.deliveries.last
162
163 assert_equal mail.body, mail2.body
164 end
147 165 end
148 166
General Comments 0
You need to be logged in to leave comments. Login now