Commit 260373ae authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

Slight changes to ease Rails 2.2 support.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2234 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 4a5d3e03
...@@ -41,7 +41,7 @@ class SettingsController < ApplicationController ...@@ -41,7 +41,7 @@ class SettingsController < ApplicationController
@deliveries = ActionMailer::Base.perform_deliveries @deliveries = ActionMailer::Base.perform_deliveries
@guessed_host_and_path = request.host_with_port @guessed_host_and_path = request.host_with_port
@guessed_host_and_path << ('/'+ request.relative_url_root.gsub(%r{^\/}, '')) unless request.relative_url_root.blank? @guessed_host_and_path << ('/'+ Redmine::Utils.relative_url_root.gsub(%r{^\/}, '')) unless Redmine::Utils.relative_url_root.blank?
end end
def plugin def plugin
......
...@@ -191,7 +191,7 @@ class Mailer < ActionMailer::Base ...@@ -191,7 +191,7 @@ class Mailer < ActionMailer::Base
# URL options # URL options
h = Setting.host_name h = Setting.host_name
h = h.to_s.gsub(%r{\/.*$}, '') unless ActionController::AbstractRequest.relative_url_root.blank? h = h.to_s.gsub(%r{\/.*$}, '') unless Redmine::Utils.relative_url_root.blank?
default_url_options[:host] = h default_url_options[:host] = h
default_url_options[:protocol] = Setting.protocol default_url_options[:protocol] = Setting.protocol
...@@ -226,7 +226,7 @@ class Mailer < ActionMailer::Base ...@@ -226,7 +226,7 @@ class Mailer < ActionMailer::Base
# Renders a message with the corresponding layout # Renders a message with the corresponding layout
def render_message(method_name, body) def render_message(method_name, body)
layout = method_name.match(%r{text\.html\.(rhtml|rxml)}) ? 'layout.text.html.rhtml' : 'layout.text.plain.rhtml' layout = method_name.to_s.match(%r{text\.html\.(rhtml|rxml)}) ? 'layout.text.html.rhtml' : 'layout.text.plain.rhtml'
body[:content_for_layout] = render(:file => method_name, :body => body) body[:content_for_layout] = render(:file => method_name, :body => body)
ActionView::Base.new(template_root, body, self).render(:file => "mailer/#{layout}", :use_full_path => true) ActionView::Base.new(template_root, body, self).render(:file => "mailer/#{layout}", :use_full_path => true)
end end
......
# Redmine - project management software
# Copyright (C) 2006-2009 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module Redmine
module Utils
class << self
# Returns the relative root url of the application
def relative_url_root
ActionController::Base.respond_to?('relative_url_root') ?
ActionController::Base.relative_url_root.to_s :
ActionController::AbstractRequest.relative_url_root.to_s
end
# Sets the relative root url of the application
def relative_url_root=(arg)
if ActionController::Base.respond_to?('relative_url_root=')
ActionController::Base.relative_url_root=arg
else
ActionController::AbstractRequest.relative_url_root=arg
end
end
end
end
end
...@@ -21,8 +21,7 @@ module Redmine ...@@ -21,8 +21,7 @@ module Redmine
module Helper module Helper
def wikitoolbar_for(field_id) def wikitoolbar_for(field_id)
# Is there a simple way to link to a public resource? # Is there a simple way to link to a public resource?
prefix = (ActionController::Base.respond_to?(:relative_url_root) ? ActionController::Base.relative_url_root : ActionController::AbstractRequest.relative_url_root) url = "#{Redmine::Utils.relative_url_root}/help/wiki_syntax.html"
url = "#{prefix}/help/wiki_syntax.html"
help_link = l(:setting_text_formatting) + ': ' + help_link = l(:setting_text_formatting) + ': ' +
link_to(l(:label_help), url, link_to(l(:label_help), url,
......
...@@ -40,11 +40,11 @@ class MailerTest < Test::Unit::TestCase ...@@ -40,11 +40,11 @@ class MailerTest < Test::Unit::TestCase
end end
def test_generated_links_with_prefix def test_generated_links_with_prefix
relative_url_root = ActionController::AbstractRequest.relative_url_root relative_url_root = Redmine::Utils.relative_url_root
ActionMailer::Base.deliveries.clear ActionMailer::Base.deliveries.clear
Setting.host_name = 'mydomain.foo/rdm' Setting.host_name = 'mydomain.foo/rdm'
Setting.protocol = 'http' Setting.protocol = 'http'
ActionController::AbstractRequest.relative_url_root = '/rdm' Redmine::Utils.relative_url_root = '/rdm'
journal = Journal.find(2) journal = Journal.find(2)
assert Mailer.deliver_issue_edit(journal) assert Mailer.deliver_issue_edit(journal)
...@@ -60,15 +60,15 @@ class MailerTest < Test::Unit::TestCase ...@@ -60,15 +60,15 @@ class MailerTest < Test::Unit::TestCase
assert mail.body.include?('<a href="http://mydomain.foo/rdm/repositories/revision/ecookbook/2" class="changeset" title="This commit fixes #1, #2 and references #1 &amp; #3">r2</a>') assert mail.body.include?('<a href="http://mydomain.foo/rdm/repositories/revision/ecookbook/2" class="changeset" title="This commit fixes #1, #2 and references #1 &amp; #3">r2</a>')
ensure ensure
# restore it # restore it
ActionController::AbstractRequest.relative_url_root = relative_url_root Redmine::Utils.relative_url_root = relative_url_root
end end
def test_generated_links_with_prefix_and_no_relative_url_root def test_generated_links_with_prefix_and_no_relative_url_root
relative_url_root = ActionController::AbstractRequest.relative_url_root relative_url_root = Redmine::Utils.relative_url_root
ActionMailer::Base.deliveries.clear ActionMailer::Base.deliveries.clear
Setting.host_name = 'mydomain.foo/rdm' Setting.host_name = 'mydomain.foo/rdm'
Setting.protocol = 'http' Setting.protocol = 'http'
ActionController::AbstractRequest.relative_url_root = nil Redmine::Utils.relative_url_root = nil
journal = Journal.find(2) journal = Journal.find(2)
assert Mailer.deliver_issue_edit(journal) assert Mailer.deliver_issue_edit(journal)
...@@ -84,7 +84,7 @@ class MailerTest < Test::Unit::TestCase ...@@ -84,7 +84,7 @@ class MailerTest < Test::Unit::TestCase
assert mail.body.include?('<a href="http://mydomain.foo/rdm/repositories/revision/ecookbook/2" class="changeset" title="This commit fixes #1, #2 and references #1 &amp; #3">r2</a>') assert mail.body.include?('<a href="http://mydomain.foo/rdm/repositories/revision/ecookbook/2" class="changeset" title="This commit fixes #1, #2 and references #1 &amp; #3">r2</a>')
ensure ensure
# restore it # restore it
ActionController::AbstractRequest.relative_url_root = relative_url_root Redmine::Utils.relative_url_root = relative_url_root
end end
def test_plain_text_mail def test_plain_text_mail
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment