mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Cleanup deprecation warnings in Action Controller
Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
committed by
José Valim
parent
ed2650646e
commit
11fccc5f06
@@ -5,19 +5,6 @@ module ActionController
|
||||
class ::ActionController::ActionControllerError < StandardError #:nodoc:
|
||||
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
|
||||
included do
|
||||
::ActionController::UnknownAction = ::AbstractController::ActionNotFound
|
||||
|
||||
@@ -58,16 +58,6 @@ module ActionController
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
def helpers_dir
|
||||
ActiveSupport::Deprecation.warn "helpers_dir is deprecated, use helpers_path instead", caller
|
||||
self.helpers_path
|
||||
end
|
||||
|
||||
def helpers_dir=(value)
|
||||
ActiveSupport::Deprecation.warn "helpers_dir= is deprecated, use helpers_path= instead", caller
|
||||
self.helpers_path = Array.wrap(value)
|
||||
end
|
||||
|
||||
# Declares helper accessors for controller attributes. For example, the
|
||||
# following adds new +name+ and <tt>name=</tt> instance methods to a
|
||||
# controller and makes them available to the view:
|
||||
@@ -87,7 +77,7 @@ module ActionController
|
||||
|
||||
private
|
||||
# Overwrite modules_for_helpers to accept :all as argument, which loads
|
||||
# all helpers in helpers_dir.
|
||||
# all helpers in helpers_path.
|
||||
#
|
||||
# ==== Parameters
|
||||
# * <tt>args</tt> - A list of helpers
|
||||
|
||||
@@ -69,10 +69,6 @@ module ActionController #:nodoc:
|
||||
options[:filename] ||= File.basename(path) unless options[:url_based_filename]
|
||||
send_file_headers! options
|
||||
|
||||
if options[:x_sendfile]
|
||||
ActiveSupport::Deprecation.warn(":x_sendfile is no longer needed in send_file", caller)
|
||||
end
|
||||
|
||||
self.status = options[:status] || 200
|
||||
self.content_type = options[:content_type] if options.key?(:content_type)
|
||||
self.response_body = File.open(path, "rb")
|
||||
@@ -121,10 +117,6 @@ module ActionController #:nodoc:
|
||||
raise ArgumentError, ":#{arg} option required" if options[arg].nil?
|
||||
end
|
||||
|
||||
if options.key?(:length)
|
||||
ActiveSupport::Deprecation.warn("You do not need to provide the file's length", caller)
|
||||
end
|
||||
|
||||
disposition = options[:disposition]
|
||||
disposition += %(; filename="#{options[:filename]}") if options[:filename]
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@ require "rails"
|
||||
require "action_controller"
|
||||
require "action_dispatch/railtie"
|
||||
require "action_view/railtie"
|
||||
require "active_support/deprecation/proxy_wrappers"
|
||||
require "active_support/deprecation"
|
||||
require "abstract_controller/railties/routes_helpers"
|
||||
require "action_controller/railties/paths"
|
||||
|
||||
@@ -11,28 +9,6 @@ module ActionController
|
||||
class Railtie < Rails::Railtie
|
||||
config.action_controller = ActiveSupport::OrderedOptions.new
|
||||
|
||||
config.action_controller.singleton_class.tap do |d|
|
||||
d.send(:define_method, :session) do
|
||||
ActiveSupport::Deprecation.warn "config.action_controller.session has been deprecated. " <<
|
||||
"Please use Rails.application.config.session_store instead.", caller
|
||||
end
|
||||
|
||||
d.send(:define_method, :session=) do |val|
|
||||
ActiveSupport::Deprecation.warn "config.action_controller.session= has been deprecated. " <<
|
||||
"Please use config.session_store(name, options) instead.", caller
|
||||
end
|
||||
|
||||
d.send(:define_method, :session_store) do
|
||||
ActiveSupport::Deprecation.warn "config.action_controller.session_store has been deprecated. " <<
|
||||
"Please use Rails.application.config.session_store instead.", caller
|
||||
end
|
||||
|
||||
d.send(:define_method, :session_store=) do |val|
|
||||
ActiveSupport::Deprecation.warn "config.action_controller.session_store= has been deprecated. " <<
|
||||
"Please use config.session_store(name, options) instead.", caller
|
||||
end
|
||||
end
|
||||
|
||||
initializer "action_controller.logger" do
|
||||
ActiveSupport.on_load(:action_controller) { self.logger ||= Rails.logger }
|
||||
end
|
||||
@@ -57,13 +33,5 @@ module ActionController
|
||||
options.each { |k,v| send("#{k}=", v) }
|
||||
end
|
||||
end
|
||||
|
||||
initializer "action_controller.deprecated_routes" do |app|
|
||||
message = "ActionController::Routing::Routes is deprecated. " \
|
||||
"Instead, use Rails.application.routes"
|
||||
|
||||
proxy = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(app.routes, message)
|
||||
ActionController::Routing::Routes = proxy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -42,7 +42,7 @@ class JustMeController < ActionController::Base
|
||||
def flash
|
||||
render :inline => "<h1><%= notice %></h1>"
|
||||
end
|
||||
|
||||
|
||||
def lib
|
||||
render :inline => '<%= useful_function %>'
|
||||
end
|
||||
@@ -178,17 +178,6 @@ class HelperTest < ActiveSupport::TestCase
|
||||
assert methods.include?('foobar')
|
||||
end
|
||||
|
||||
def test_deprecation
|
||||
assert_deprecated do
|
||||
ActionController::Base.helpers_dir = "some/foo/bar"
|
||||
end
|
||||
assert_deprecated do
|
||||
assert_equal ["some/foo/bar"], ActionController::Base.helpers_dir
|
||||
end
|
||||
ensure
|
||||
ActionController::Base.helpers_path = File.expand_path('../../fixtures/helpers', __FILE__)
|
||||
end
|
||||
|
||||
private
|
||||
def expected_helper_methods
|
||||
TestHelper.instance_methods.map {|m| m.to_s }
|
||||
|
||||
@@ -16,10 +16,6 @@ module Another
|
||||
send_data "cool data", :filename => "file.txt"
|
||||
end
|
||||
|
||||
def xfile_sender
|
||||
send_file File.expand_path("company.rb", FIXTURE_LOAD_PATH), :x_sendfile => true
|
||||
end
|
||||
|
||||
def file_sender
|
||||
send_file File.expand_path("company.rb", FIXTURE_LOAD_PATH)
|
||||
end
|
||||
@@ -133,15 +129,6 @@ class ACLogSubscriberTest < ActionController::TestCase
|
||||
assert_match /test\/fixtures\/company\.rb/, logs[1]
|
||||
end
|
||||
|
||||
def test_send_xfile
|
||||
assert_deprecated { get :xfile_sender }
|
||||
wait
|
||||
|
||||
assert_equal 3, logs.size
|
||||
assert_match /Sent file/, logs[1]
|
||||
assert_match /test\/fixtures\/company\.rb/, logs[1]
|
||||
end
|
||||
|
||||
def test_with_fragment_cache
|
||||
@controller.config.perform_caching = true
|
||||
get :with_fragment_cache
|
||||
|
||||
@@ -658,36 +658,6 @@ class ResourcesTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_resource_action_separator
|
||||
with_routing do |set|
|
||||
set.draw do
|
||||
scope '/threads/:thread_id' do
|
||||
resources :messages, :as => :thread_messages do
|
||||
get :search, :on => :collection
|
||||
match :preview, :on => :new
|
||||
end
|
||||
end
|
||||
scope '/admin' do
|
||||
resource :account, :as => :admin_account do
|
||||
get :login, :on => :member
|
||||
match :preview, :on => :new
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action_separator = ActionController::Base.resource_action_separator
|
||||
|
||||
assert_simply_restful_for :messages, :name_prefix => 'thread_', :path_prefix => 'threads/1/', :options => { :thread_id => '1' }
|
||||
assert_named_route "/threads/1/messages#{action_separator}search", "search_thread_messages_path", {}
|
||||
assert_named_route "/threads/1/messages/new", "new_thread_message_path", {}
|
||||
assert_named_route "/threads/1/messages/new#{action_separator}preview", "preview_new_thread_message_path", {}
|
||||
assert_singleton_restful_for :account, :name_prefix => 'admin_', :path_prefix => 'admin/'
|
||||
assert_named_route "/admin/account#{action_separator}login", "login_admin_account_path", {}
|
||||
assert_named_route "/admin/account/new", "new_admin_account_path", {}
|
||||
assert_named_route "/admin/account/new#{action_separator}preview", "preview_new_admin_account_path", {}
|
||||
end
|
||||
end
|
||||
|
||||
def test_new_style_named_routes_for_resource
|
||||
with_routing do |set|
|
||||
set.draw do
|
||||
|
||||
@@ -143,8 +143,6 @@ WARNING: Threadsafe operation is incompatible with the normal workings of develo
|
||||
|
||||
* +config.action_controller.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then used to log information from Action Controller. Set to nil to disable logging.
|
||||
|
||||
* +config.action_controller.resource_action_separator+ gives the token to be used between resources and actions when building or interpreting RESTful URLs. By default, this is "/".
|
||||
|
||||
* +config.action_controller.resource_path_names+ is a hash of default names for several RESTful actions. By default, the new action is named +new+ and the edit action is named +edit+.
|
||||
|
||||
* +config.action_controller.request_forgery_protection_token+ sets the token parameter name for RequestForgery. Calling +protect_from_forgery+ sets it to +:authenticity_token+ by default.
|
||||
|
||||
Reference in New Issue
Block a user