Skip to content

Commit 8c495e2

Browse files
kareschadlwilson
authored andcommitted
setting of relative_url_root isn't really needed
since the Rails::Configuration default is: @relative_url_root = ENV["RAILS_RELATIVE_URL_ROOT"] (cherry picked from commit a59475d)
1 parent 158ce55 commit 8c495e2

File tree

2 files changed

+0
-74
lines changed

2 files changed

+0
-74
lines changed

src/main/ruby/jruby/rack/rails/railtie.rb

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,6 @@ class Railtie < ::Rails::Railtie
5858
end
5959
end
6060

61-
initializer 'set_relative_url_root', :after => 'action_controller.set_configs' do |app|
62-
# NOTE: this is most likely handled by Rails 3.x itself :
63-
# - *config.relative_url_root* since 3.2 defaults to _RAILS_RELATIVE_URL_ROOT_
64-
# - *config.action_controller.relative_url_root* is set from *config.relative_url_root*
65-
# - when a *config.relative_url_root* is set we should not interfere ...
66-
if ( env_url_root = ENV['RAILS_RELATIVE_URL_ROOT'] ) &&
67-
!( app.config.respond_to?(:relative_url_root) && app.config.relative_url_root )
68-
if action_controller = app.config.action_controller
69-
action_controller.relative_url_root = env_url_root
70-
elsif defined?(ActionController::Base) &&
71-
ActionController::Base.respond_to?(:relative_url_root=)
72-
# setting the config affects *ActionController::Base.relative_url_root*
73-
ActionController::Base.config.relative_url_root = env_url_root
74-
end
75-
end
76-
end
77-
7861
initializer 'action_dispatch.autoload_java_servlet_store', :after => 'action_dispatch.configure' do
7962
# if it's loaded up front with a require 'action_controller'/'action_dispatch' then
8063
# it might fire up before 'active_record' has been required causing sweeping issues

src/spec/ruby/jruby/rack/rails_booter_spec.rb

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -254,63 +254,6 @@ def log_initializer
254254
booter.to_app.should == app
255255
end
256256

257-
it "should set config.action_controller.relative_url_root based on ENV['RAILS_RELATIVE_URL_ROOT']" do
258-
ENV['RAILS_RELATIVE_URL_ROOT'] = '/blah'
259-
app = double "app"
260-
app.stub_chain(:config, :action_controller, :relative_url_root)
261-
app.config.action_controller.should_receive(:relative_url_root=).with("/blah")
262-
before_config = Rails::Railtie.__initializer.detect { |i| i.first =~ /url/ }
263-
before_config.should_not be_nil
264-
before_config[1].should == [{:after => "action_controller.set_configs"}]
265-
before_config.last.call(app)
266-
end
267-
268-
end # if defined? Rails
269-
270-
# NOTE: specs currently only test with a stubbed Rails::Railtie
271-
describe "Rails 3.1", :lib => [ :stub ] do
272-
273-
before :each do
274-
$servlet_context = @servlet_context
275-
#booter.layout_class = JRuby::Rack::FileSystemLayout
276-
booter.app_path = RAILS_ROOT_DIR.dup
277-
def booter.rails2?; false end
278-
booter.boot!
279-
booter.load_environment
280-
end
281-
282-
after :all do
283-
$servlet_context = nil
284-
end
285-
286-
#
287-
# relative_url_root= has been deprecated in Rails > 3. We should not call it when it's not defined.
288-
# See: https://github.com/jruby/jruby-rack/issues/73
289-
# https://github.com/rails/rails/issues/2435
290-
#
291-
it "should not set config.action_controller.relative_url_root if the controller doesn't respond to that method" do
292-
require 'action_controller' # stub
293-
begin
294-
#ActionController::Base.send :remove_method, :relative_url_root=
295-
ENV['RAILS_RELATIVE_URL_ROOT'] = '/blah'
296-
app = double "app"
297-
app.stub_chain(:config, :action_controller)
298-
app.config.stub(:action_controller).and_return(nil)
299-
# app.config.action_controller.should_not_receive(:relative_url_root=)
300-
ActionController::Base.stub(:config).and_return app.config
301-
302-
app.config.should_receive(:relative_url_root=).with('/blah')
303-
ActionController::Base.should_not_receive(:relative_url_root=)
304-
305-
init = Rails::Railtie.__initializer.detect { |i| i.first =~ /url/ }
306-
init.should_not be nil
307-
init[1].should == [{:after => "action_controller.set_configs"}]
308-
init.last.call(app)
309-
ensure
310-
#ActionController::Base.send :attr_writer, :relative_url_root
311-
end
312-
end
313-
314257
end # if defined? Rails
315258

316259
end

0 commit comments

Comments
 (0)