Browse Source

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
tags/0.9.0
Jean-Philippe Lang 15 years ago
parent
commit
260373aed7

+ 1
- 1
app/controllers/settings_controller.rb View File

@@ -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

+ 2
- 2
app/models/mailer.rb View File

@@ -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

+ 38
- 0
lib/redmine/utils.rb View File

@@ -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

+ 1
- 2
lib/redmine/wiki_formatting/textile/helper.rb View File

@@ -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,

+ 6
- 6
test/unit/mailer_test.rb View File

@@ -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 &amp; #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 &amp; #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

Loading…
Cancel
Save