Skip to content

Commit a59475d

Browse files
committed
setting of relative_url_root isn't really needed
since the Rails::Configuration default is: @relative_url_root = ENV["RAILS_RELATIVE_URL_ROOT"]
1 parent 3df69b4 commit a59475d

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
@@ -45,23 +45,6 @@ class Railtie < ::Rails::Railtie
4545
end
4646
end
4747

48-
initializer 'set_relative_url_root', :after => 'action_controller.set_configs' do |app|
49-
# NOTE: this is most likely handled by Rails 3.x itself :
50-
# - *config.relative_url_root* since 3.2 defaults to _RAILS_RELATIVE_URL_ROOT_
51-
# - *config.action_controller.relative_url_root* is set from *config.relative_url_root*
52-
# - when a *config.relative_url_root* is set we should not interfere ...
53-
if ( env_url_root = ENV['RAILS_RELATIVE_URL_ROOT'] ) &&
54-
!( app.config.respond_to?(:relative_url_root) && app.config.relative_url_root )
55-
if action_controller = app.config.action_controller
56-
action_controller.relative_url_root = env_url_root
57-
elsif defined?(ActionController::Base) &&
58-
ActionController::Base.respond_to?(:relative_url_root=)
59-
# setting the config affects *ActionController::Base.relative_url_root*
60-
ActionController::Base.config.relative_url_root = env_url_root
61-
end
62-
end
63-
end
64-
6548
initializer 'action_dispatch.autoload_java_servlet_store', :after => 'action_dispatch.configure' do
6649
# if it's loaded up front with a require 'action_controller'/'action_dispatch' then
6750
# 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
@@ -242,63 +242,6 @@ def log_initializer
242242
booter.to_app.should == app
243243
end
244244

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

304247
end

0 commit comments

Comments
 (0)