mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove deprecated support to <% form_for %> and several ActionController::Base methods.
This commit is contained in:
parent
800695ad4c
commit
ba52748d05
12 changed files with 34 additions and 317 deletions
|
@ -34,7 +34,6 @@ module ActionController
|
|||
autoload :UrlFor
|
||||
end
|
||||
|
||||
autoload :Dispatcher, 'action_controller/deprecated/dispatcher'
|
||||
autoload :Integration, 'action_controller/deprecated/integration_test'
|
||||
autoload :IntegrationTest, 'action_controller/deprecated/integration_test'
|
||||
autoload :PerformanceTest, 'action_controller/deprecated/performance_test'
|
||||
|
|
|
@ -228,6 +228,4 @@ module ActionController
|
|||
|
||||
ActiveSupport.run_load_hooks(:action_controller, self)
|
||||
end
|
||||
end
|
||||
|
||||
require "action_controller/deprecated/base"
|
||||
end
|
|
@ -1,3 +1,3 @@
|
|||
ActionController::AbstractRequest = ActionController::Request = ActionDispatch::Request
|
||||
ActionController::AbstractResponse = ActionController::Response = ActionDispatch::Response
|
||||
ActionController::Routing = ActionDispatch::Routing
|
||||
ActionController::Routing = ActionDispatch::Routing
|
|
@ -1,133 +0,0 @@
|
|||
module ActionController
|
||||
class Base
|
||||
# Deprecated methods. Wrap them in a module so they can be overwritten by plugins
|
||||
# (like the verify method.)
|
||||
module DeprecatedBehavior #:nodoc:
|
||||
def relative_url_root
|
||||
ActiveSupport::Deprecation.warn "ActionController::Base.relative_url_root is ineffective. " <<
|
||||
"Please stop using it.", caller
|
||||
end
|
||||
|
||||
def relative_url_root=
|
||||
ActiveSupport::Deprecation.warn "ActionController::Base.relative_url_root= is ineffective. " <<
|
||||
"Please stop using it.", caller
|
||||
end
|
||||
|
||||
def consider_all_requests_local
|
||||
ActiveSupport::Deprecation.warn "ActionController::Base.consider_all_requests_local is deprecated, " <<
|
||||
"use Rails.application.config.consider_all_requests_local instead", caller
|
||||
Rails.application.config.consider_all_requests_local
|
||||
end
|
||||
|
||||
def consider_all_requests_local=(value)
|
||||
ActiveSupport::Deprecation.warn "ActionController::Base.consider_all_requests_local= is deprecated. " <<
|
||||
"Please configure it on your application with config.consider_all_requests_local=", caller
|
||||
Rails.application.config.consider_all_requests_local = value
|
||||
end
|
||||
|
||||
def allow_concurrency
|
||||
ActiveSupport::Deprecation.warn "ActionController::Base.allow_concurrency is deprecated, " <<
|
||||
"use Rails.application.config.allow_concurrency instead", caller
|
||||
Rails.application.config.allow_concurrency
|
||||
end
|
||||
|
||||
def allow_concurrency=(value)
|
||||
ActiveSupport::Deprecation.warn "ActionController::Base.allow_concurrency= is deprecated. " <<
|
||||
"Please configure it on your application with config.allow_concurrency=", caller
|
||||
Rails.application.config.allow_concurrency = value
|
||||
end
|
||||
|
||||
def ip_spoofing_check=(value)
|
||||
ActiveSupport::Deprecation.warn "ActionController::Base.ip_spoofing_check= is deprecated. " <<
|
||||
"Please configure it on your application with config.action_dispatch.ip_spoofing_check=", caller
|
||||
Rails.application.config.action_dispatch.ip_spoofing_check = value
|
||||
end
|
||||
|
||||
def ip_spoofing_check
|
||||
ActiveSupport::Deprecation.warn "ActionController::Base.ip_spoofing_check is deprecated. " <<
|
||||
"Configuring ip_spoofing_check on the application configures a middleware.", caller
|
||||
Rails.application.config.action_dispatch.ip_spoofing_check
|
||||
end
|
||||
|
||||
def cookie_verifier_secret=(value)
|
||||
ActiveSupport::Deprecation.warn "ActionController::Base.cookie_verifier_secret= is deprecated. " <<
|
||||
"Please configure it on your application with config.secret_token=", caller
|
||||
end
|
||||
|
||||
def cookie_verifier_secret
|
||||
ActiveSupport::Deprecation.warn "ActionController::Base.cookie_verifier_secret is deprecated.", caller
|
||||
end
|
||||
|
||||
def trusted_proxies=(value)
|
||||
ActiveSupport::Deprecation.warn "ActionController::Base.trusted_proxies= is deprecated. " <<
|
||||
"Please configure it on your application with config.action_dispatch.trusted_proxies=", caller
|
||||
Rails.application.config.action_dispatch.ip_spoofing_check = value
|
||||
end
|
||||
|
||||
def trusted_proxies
|
||||
ActiveSupport::Deprecation.warn "ActionController::Base.trusted_proxies is deprecated. " <<
|
||||
"Configuring trusted_proxies on the application configures a middleware.", caller
|
||||
Rails.application.config.action_dispatch.ip_spoofing_check = value
|
||||
end
|
||||
|
||||
def session(*args)
|
||||
ActiveSupport::Deprecation.warn(
|
||||
"Disabling sessions for a single controller has been deprecated. " +
|
||||
"Sessions are now lazy loaded. So if you don't access them, " +
|
||||
"consider them off. You can still modify the session cookie " +
|
||||
"options with request.session_options.", caller)
|
||||
end
|
||||
|
||||
def session=(value)
|
||||
ActiveSupport::Deprecation.warn "ActionController::Base.session= is deprecated. " <<
|
||||
"Please configure it on your application with config.session_store :cookie_store, :key => '....'", caller
|
||||
if value.delete(:disabled)
|
||||
Rails.application.config.session_store :disabled
|
||||
else
|
||||
store = Rails.application.config.session_store
|
||||
Rails.application.config.session_store store, value
|
||||
end
|
||||
end
|
||||
|
||||
# Controls the resource action separator
|
||||
def resource_action_separator
|
||||
@resource_action_separator ||= "/"
|
||||
end
|
||||
|
||||
def resource_action_separator=(val)
|
||||
ActiveSupport::Deprecation.warn "ActionController::Base.resource_action_separator is deprecated and only " \
|
||||
"works with the deprecated router DSL."
|
||||
@resource_action_separator = val
|
||||
end
|
||||
|
||||
def use_accept_header
|
||||
ActiveSupport::Deprecation.warn "ActionController::Base.use_accept_header doesn't do anything anymore. " \
|
||||
"The accept header is always taken into account."
|
||||
end
|
||||
|
||||
def use_accept_header=(val)
|
||||
use_accept_header
|
||||
end
|
||||
|
||||
# This method has been moved to ActionDispatch::Request.filter_parameters
|
||||
def filter_parameter_logging(*args, &block)
|
||||
ActiveSupport::Deprecation.warn("Setting filter_parameter_logging in ActionController is deprecated and has no longer effect, please set 'config.filter_parameters' in config/application.rb instead", caller)
|
||||
filter = Rails.application.config.filter_parameters
|
||||
filter.concat(args)
|
||||
filter << block if block
|
||||
filter
|
||||
end
|
||||
|
||||
# This was moved to a plugin
|
||||
def verify(*args)
|
||||
ActiveSupport::Deprecation.warn "verify was removed from Rails and is now available as a plugin. " <<
|
||||
"Please install it with `rails plugin install git://github.com/rails/verification.git`.", caller
|
||||
end
|
||||
end
|
||||
|
||||
extend DeprecatedBehavior
|
||||
|
||||
delegate :consider_all_requests_local, :consider_all_requests_local=,
|
||||
:allow_concurrency, :allow_concurrency=, :to => :"self.class"
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
module ActionController
|
||||
class Dispatcher
|
||||
class << self
|
||||
def before_dispatch(*args, &block)
|
||||
ActiveSupport::Deprecation.warn "ActionController::Dispatcher.before_dispatch is deprecated. " <<
|
||||
"Please use ActionDispatch::Callbacks.before instead.", caller
|
||||
ActionDispatch::Callbacks.before(*args, &block)
|
||||
end
|
||||
|
||||
def after_dispatch(*args, &block)
|
||||
ActiveSupport::Deprecation.warn "ActionController::Dispatcher.after_dispatch is deprecated. " <<
|
||||
"Please use ActionDispatch::Callbacks.after instead.", caller
|
||||
ActionDispatch::Callbacks.after(*args, &block)
|
||||
end
|
||||
|
||||
def to_prepare(*args, &block)
|
||||
ActiveSupport::Deprecation.warn "ActionController::Dispatcher.to_prepare is deprecated. " <<
|
||||
"Please use config.to_prepare instead", caller
|
||||
ActionDispatch::Callbacks.after(*args, &block)
|
||||
end
|
||||
|
||||
def new
|
||||
ActiveSupport::Deprecation.warn "ActionController::Dispatcher.new is deprecated, use Rails.application instead."
|
||||
Rails.application
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -6,6 +6,16 @@ module ActionController
|
|||
end
|
||||
|
||||
module ClassMethods
|
||||
# TODO Remove this after the old router map is removed.
|
||||
def resource_action_separator
|
||||
@resource_action_separator ||= "/"
|
||||
end
|
||||
|
||||
# TODO Remove this after the old router map is removed.
|
||||
def resource_action_separator=(val)
|
||||
ActiveSupport::Deprecation.warn "ActionController::Base.resource_action_separator is deprecated"
|
||||
@resource_action_separator = val
|
||||
end
|
||||
end
|
||||
|
||||
# Temporary hax
|
||||
|
@ -39,12 +49,6 @@ module ActionController
|
|||
def assign_shortcuts(*) end
|
||||
|
||||
def _normalize_options(options)
|
||||
if options[:action] && options[:action].to_s.include?(?/)
|
||||
ActiveSupport::Deprecation.warn "Giving a path to render :action is deprecated. " <<
|
||||
"Please use render :template instead", caller
|
||||
options[:template] = options.delete(:action)
|
||||
end
|
||||
|
||||
options[:text] = nil if options.delete(:nothing) == true
|
||||
options[:text] = " " if options.key?(:text) && options[:text].nil?
|
||||
super
|
||||
|
|
|
@ -14,13 +14,6 @@ module ActionView
|
|||
super(value.to_s)
|
||||
end
|
||||
alias :append= :<<
|
||||
|
||||
def append_if_string=(value)
|
||||
if value.is_a?(String) && !value.is_a?(NonConcattingString)
|
||||
ActiveSupport::Deprecation.warn("<% %> style block helpers are deprecated. Please use <%= %>", caller)
|
||||
self << value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Template
|
||||
|
@ -45,14 +38,6 @@ module ActionView
|
|||
end
|
||||
end
|
||||
|
||||
def add_stmt(src, code)
|
||||
if code =~ BLOCK_EXPR
|
||||
src << '@output_buffer.append_if_string= ' << code
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def add_expr_escaped(src, code)
|
||||
src << '@output_buffer.append= ' << escaped_expr(code) << ';'
|
||||
end
|
||||
|
|
|
@ -15,10 +15,8 @@ class AssertSelectTest < ActionController::TestCase
|
|||
|
||||
class AssertSelectMailer < ActionMailer::Base
|
||||
def test(html)
|
||||
recipients "test <test@test.host>"
|
||||
from "test@test.host"
|
||||
subject "Test e-mail"
|
||||
part :content_type=>"text/html", :body=>html
|
||||
mail :body => html, :content_type => "text/html",
|
||||
:subject => "Test e-mail", :from => "test@test.host", :to => "test <test@test.host>"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -100,20 +100,6 @@ class ControllerClassTests < ActiveSupport::TestCase
|
|||
assert_equal 'contained_empty', Submodule::ContainedEmptyController.controller_name
|
||||
end
|
||||
|
||||
def test_filter_parameter_logging
|
||||
parameters = []
|
||||
config = mock(:config => mock(:filter_parameters => parameters))
|
||||
Rails.expects(:application).returns(config)
|
||||
|
||||
assert_deprecated do
|
||||
Class.new(ActionController::Base) do
|
||||
filter_parameter_logging :password
|
||||
end
|
||||
end
|
||||
|
||||
assert_equal [:password], parameters
|
||||
end
|
||||
|
||||
def test_record_identifier
|
||||
assert_respond_to RecordIdentifierController.new, :dom_id
|
||||
assert_respond_to RecordIdentifierController.new, :dom_class
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
require 'abstract_unit'
|
||||
|
||||
# Ensure deprecated dispatcher works
|
||||
class DeprecatedDispatcherTest < ActiveSupport::TestCase
|
||||
class DummyApp
|
||||
def call(env)
|
||||
[200, {}, 'response']
|
||||
end
|
||||
end
|
||||
|
||||
def setup
|
||||
ActionDispatch::Callbacks.reset_callbacks(:prepare)
|
||||
ActionDispatch::Callbacks.reset_callbacks(:call)
|
||||
end
|
||||
|
||||
def test_assert_deprecated_to_prepare
|
||||
a = nil
|
||||
|
||||
assert_deprecated do
|
||||
ActionController::Dispatcher.to_prepare { a = 1 }
|
||||
end
|
||||
|
||||
assert_nil a
|
||||
dispatch
|
||||
assert_equal 1, a
|
||||
end
|
||||
|
||||
def test_assert_deprecated_before_dispatch
|
||||
a = nil
|
||||
|
||||
assert_deprecated do
|
||||
ActionController::Dispatcher.before_dispatch { a = 1 }
|
||||
end
|
||||
|
||||
assert_nil a
|
||||
dispatch
|
||||
assert_equal 1, a
|
||||
end
|
||||
|
||||
def test_assert_deprecated_after_dispatch
|
||||
a = nil
|
||||
|
||||
assert_deprecated do
|
||||
ActionController::Dispatcher.after_dispatch { a = 1 }
|
||||
end
|
||||
|
||||
assert_nil a
|
||||
dispatch
|
||||
assert_equal 1, a
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def dispatch(cache_classes = true)
|
||||
@dispatcher ||= ActionDispatch::Callbacks.new(DummyApp.new, !cache_classes)
|
||||
@dispatcher.call({'rack.input' => StringIO.new('')})
|
||||
end
|
||||
|
||||
end
|
|
@ -2,59 +2,35 @@ require "abstract_unit"
|
|||
require "template/erb/helper"
|
||||
|
||||
module ERBTest
|
||||
module SharedTagHelpers
|
||||
extend ActiveSupport::Testing::Declarative
|
||||
|
||||
def maybe_deprecated
|
||||
if @deprecated
|
||||
assert_deprecated { yield }
|
||||
else
|
||||
yield
|
||||
end
|
||||
end
|
||||
|
||||
test "percent equals works for content_tag and does not require parenthesis on method call" do
|
||||
maybe_deprecated { assert_equal "<div>Hello world</div>", render_content("content_tag :div", "Hello world") }
|
||||
end
|
||||
|
||||
test "percent equals works for javascript_tag" do
|
||||
expected_output = "<script type=\"text/javascript\">\n//<![CDATA[\nalert('Hello')\n//]]>\n</script>"
|
||||
maybe_deprecated { assert_equal expected_output, render_content("javascript_tag", "alert('Hello')") }
|
||||
end
|
||||
|
||||
test "percent equals works for javascript_tag with options" do
|
||||
expected_output = "<script id=\"the_js_tag\" type=\"text/javascript\">\n//<![CDATA[\nalert('Hello')\n//]]>\n</script>"
|
||||
maybe_deprecated { assert_equal expected_output, render_content("javascript_tag(:id => 'the_js_tag')", "alert('Hello')") }
|
||||
end
|
||||
|
||||
test "percent equals works with form tags" do
|
||||
expected_output = %r{<form.*action="foo".*method="post">.*hello*</form>}
|
||||
maybe_deprecated { assert_match expected_output, render_content("form_tag('foo')", "<%= 'hello' %>") }
|
||||
end
|
||||
|
||||
test "percent equals works with fieldset tags" do
|
||||
expected_output = "<fieldset><legend>foo</legend>hello</fieldset>"
|
||||
maybe_deprecated { assert_equal expected_output, render_content("field_set_tag('foo')", "<%= 'hello' %>") }
|
||||
end
|
||||
end
|
||||
|
||||
class TagHelperTest < BlockTestCase
|
||||
def block_helper(str, rest)
|
||||
"<%= #{str} do %>#{rest}<% end %>"
|
||||
end
|
||||
|
||||
include SharedTagHelpers
|
||||
end
|
||||
extend ActiveSupport::Testing::Declarative
|
||||
|
||||
class DeprecatedTagHelperTest < BlockTestCase
|
||||
def block_helper(str, rest)
|
||||
"<% __in_erb_template=true %><% #{str} do %>#{rest}<% end %>"
|
||||
test "percent equals works for content_tag and does not require parenthesis on method call" do
|
||||
assert_equal "<div>Hello world</div>", render_content("content_tag :div", "Hello world")
|
||||
end
|
||||
|
||||
def setup
|
||||
@deprecated = true
|
||||
test "percent equals works for javascript_tag" do
|
||||
expected_output = "<script type=\"text/javascript\">\n//<![CDATA[\nalert('Hello')\n//]]>\n</script>"
|
||||
assert_equal expected_output, render_content("javascript_tag", "alert('Hello')")
|
||||
end
|
||||
|
||||
include SharedTagHelpers
|
||||
test "percent equals works for javascript_tag with options" do
|
||||
expected_output = "<script id=\"the_js_tag\" type=\"text/javascript\">\n//<![CDATA[\nalert('Hello')\n//]]>\n</script>"
|
||||
assert_equal expected_output, render_content("javascript_tag(:id => 'the_js_tag')", "alert('Hello')")
|
||||
end
|
||||
|
||||
test "percent equals works with form tags" do
|
||||
expected_output = %r{<form.*action="foo".*method="post">.*hello*</form>}
|
||||
assert_match expected_output, render_content("form_tag('foo')", "<%= 'hello' %>")
|
||||
end
|
||||
|
||||
test "percent equals works with fieldset tags" do
|
||||
expected_output = "<fieldset><legend>foo</legend>hello</fieldset>"
|
||||
assert_equal expected_output, render_content("field_set_tag('foo')", "<%= 'hello' %>")
|
||||
end
|
||||
end
|
||||
end
|
|
@ -234,15 +234,6 @@ module RenderTestCases
|
|||
@view.render(:file => "test/hello_world.erb", :layout => "layouts/yield_with_render_inline_inside")
|
||||
end
|
||||
|
||||
|
||||
# TODO: Move to deprecated_tests.rb
|
||||
def test_render_with_nested_layout_deprecated
|
||||
assert_deprecated do
|
||||
assert_equal %(<title>title</title>\n\n<div id="column">column</div>\n<div id="content">content</div>\n),
|
||||
@view.render(:file => "test/deprecated_nested_layout.erb", :layout => "layouts/yield")
|
||||
end
|
||||
end
|
||||
|
||||
def test_render_with_nested_layout
|
||||
assert_equal %(<title>title</title>\n\n<div id="column">column</div>\n<div id="content">content</div>\n),
|
||||
@view.render(:file => "test/nested_layout.erb", :layout => "layouts/yield")
|
||||
|
|
Loading…
Reference in a new issue