diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-01-04 17:09:25 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-01-04 17:09:25 +0000 |
commit | 260373aed71ede51f4bc46e34283dd66b8be1cd8 (patch) | |
tree | 4fd848b5e3e56e2a00b9d29d8d3e087789f0680b | |
parent | 4a5d3e03531f37a46c80a976d5a38189db70a8ff (diff) | |
download | redmine-260373aed71ede51f4bc46e34283dd66b8be1cd8.tar.gz redmine-260373aed71ede51f4bc46e34283dd66b8be1cd8.zip |
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
-rw-r--r-- | app/controllers/settings_controller.rb | 2 | ||||
-rw-r--r-- | app/models/mailer.rb | 4 | ||||
-rw-r--r-- | lib/redmine/utils.rb | 38 | ||||
-rw-r--r-- | lib/redmine/wiki_formatting/textile/helper.rb | 3 | ||||
-rw-r--r-- | test/unit/mailer_test.rb | 12 |
5 files changed, 48 insertions, 11 deletions
diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index 99f7bcf08..e9bc0a601 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -41,7 +41,7 @@ class SettingsController < ApplicationController @deliveries = ActionMailer::Base.perform_deliveries @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 def plugin diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 9a0f3a501..beef97a7b 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -191,7 +191,7 @@ class Mailer < ActionMailer::Base # URL options 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[:protocol] = Setting.protocol @@ -226,7 +226,7 @@ class Mailer < ActionMailer::Base # Renders a message with the corresponding layout 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) ActionView::Base.new(template_root, body, self).render(:file => "mailer/#{layout}", :use_full_path => true) end diff --git a/lib/redmine/utils.rb b/lib/redmine/utils.rb new file mode 100644 index 000000000..02f9d3e63 --- /dev/null +++ b/lib/redmine/utils.rb @@ -0,0 +1,38 @@ +# 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 diff --git a/lib/redmine/wiki_formatting/textile/helper.rb b/lib/redmine/wiki_formatting/textile/helper.rb index 22fa35783..c4bde572b 100644 --- a/lib/redmine/wiki_formatting/textile/helper.rb +++ b/lib/redmine/wiki_formatting/textile/helper.rb @@ -21,8 +21,7 @@ module Redmine module Helper def wikitoolbar_for(field_id) # 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 = "#{prefix}/help/wiki_syntax.html" + url = "#{Redmine::Utils.relative_url_root}/help/wiki_syntax.html" help_link = l(:setting_text_formatting) + ': ' + link_to(l(:label_help), url, diff --git a/test/unit/mailer_test.rb b/test/unit/mailer_test.rb index 1fd43af5d..aded23cc3 100644 --- a/test/unit/mailer_test.rb +++ b/test/unit/mailer_test.rb @@ -40,11 +40,11 @@ class MailerTest < Test::Unit::TestCase end 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 Setting.host_name = 'mydomain.foo/rdm' Setting.protocol = 'http' - ActionController::AbstractRequest.relative_url_root = '/rdm' + Redmine::Utils.relative_url_root = '/rdm' journal = Journal.find(2) assert Mailer.deliver_issue_edit(journal) @@ -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 & #3">r2</a>') ensure # restore it - ActionController::AbstractRequest.relative_url_root = relative_url_root + Redmine::Utils.relative_url_root = relative_url_root end 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 Setting.host_name = 'mydomain.foo/rdm' Setting.protocol = 'http' - ActionController::AbstractRequest.relative_url_root = nil + Redmine::Utils.relative_url_root = nil journal = Journal.find(2) assert Mailer.deliver_issue_edit(journal) @@ -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 & #3">r2</a>') ensure # restore it - ActionController::AbstractRequest.relative_url_root = relative_url_root + Redmine::Utils.relative_url_root = relative_url_root end def test_plain_text_mail |