moves relative url root functionality into own module

pull/720/head
Jens Ulferts 11 years ago committed by Hagen Schink
parent 2542251737
commit 4f512dccd2
  1. 2
      app/controllers/settings_controller.rb
  2. 2
      app/helpers/application_helper.rb
  3. 2
      app/mailers/user_mailer.rb
  4. 2
      app/views/timelines/_timeline.html.erb
  5. 2
      lib/open_project/journal_formatter/diff.rb
  6. 8
      lib/open_project/url_root.rb
  7. 6
      test/functional/user_mailer_test.rb
  8. 4
      test/integration/lib/redmine/themes_test.rb

@ -53,7 +53,7 @@ class SettingsController < ApplicationController
@options[:user_format] = User::USER_FORMATS.keys.collect {|f| [User.current.name(f), f.to_s] }
@deliveries = ActionMailer::Base.perform_deliveries
@guessed_host_and_path = request.host_with_port.dup + Redmine::Utils.relative_url_root.to_s
@guessed_host_and_path = request.host_with_port.dup + OpenProject::UrlRoot.relative
end
end

@ -950,7 +950,7 @@ module ApplicationHelper
tags = ''
tags += javascript_tag(%Q{
window.openProject = new OpenProject({
urlRoot : '#{Redmine::Utils.relative_url_root}',
urlRoot : '#{OpenProject::UrlRoot.relative}',
loginUrl: '#{url_for :controller => "/account", :action => "login"}'
});
I18n.defaultLocale = "#{I18n.default_locale}";

@ -328,7 +328,7 @@ private
end
def self.host
if Redmine::Utils.relative_url_root.blank?
if OpenProject::UrlRoot.relative.blank?
Setting.host_name
else
Setting.host_name.to_s.gsub(%r{\/.*\z}, '')

@ -80,7 +80,7 @@ See doc/COPYRIGHT.rdoc for more details.
var config = jQuery.extend({
i18n: i18n,
project_id: '<%= timeline.project.identifier %>',
url_prefix: '<%= Redmine::Utils.relative_url_root %>',
url_prefix: '<%= OpenProject::UrlRoot.relative %>',
ui_root: jQuery("#<%= timeline_div_id %>")
}, <%= timeline.json_options %>);
jQuery(function(jQuery) {

@ -91,7 +91,7 @@ class OpenProject::JournalFormatter::Diff < JournalFormatter::Base
# setting :script_name is a hack that allows for setting the sub uri.
# I am not yet sure why url_for normally returns the sub uri but does not within
# this class.
:script_name => ::Redmine::Utils::relative_url_root }
:script_name => ::OpenProject::UrlRoot::relative }
else
{ :only_path => options[:only_path],
:protocol => Setting.protocol,

@ -27,13 +27,13 @@
# See doc/COPYRIGHT.rdoc for more details.
#++
module Redmine
module Utils
module OpenProject
module UrlRoot
class << self
attr_accessor :relative_url_root
attr_accessor :relative
end
self.relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT'] || ""
self.relative = ENV['RAILS_RELATIVE_URL_ROOT'] || ""
end
end

@ -164,10 +164,10 @@ class UserMailerTest < ActionMailer::TestCase
def test_generated_links_with_prefix_and_no_relative_url_root
Setting.default_language = 'en'
relative_url_root = Redmine::Utils.relative_url_root
relative_url_root = OpenProject::UrlRoot.relative
Setting.host_name = 'mydomain.foo/rdm'
Setting.protocol = 'http'
Redmine::Utils.relative_url_root = nil
OpenProject::UrlRoot.relative = nil
User.current = FactoryGirl.create(:admin)
@ -206,7 +206,7 @@ class UserMailerTest < ActionMailer::TestCase
end
ensure
# restore it
Redmine::Utils.relative_url_root = relative_url_root
OpenProject::UrlRoot.relative = relative_url_root
end
def test_email_headers

@ -74,7 +74,7 @@ class ThemesTest < ActionDispatch::IntegrationTest
should_eventually 'test_with_sub_uri' do
begin
Redmine::Utils.relative_url_root = '/foo'
OpenProject::UrlRoot.relative = '/foo'
@theme.javascripts << 'theme'
get '/'
@ -84,7 +84,7 @@ class ThemesTest < ActionDispatch::IntegrationTest
assert_tag :tag => 'script',
:attributes => {:src => '/foo/assets/default.js'}
ensure
Redmine::Utils.relative_url_root = ''
OpenProject::UrlRoot.relative = ''
end
end
end

Loading…
Cancel
Save